Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -1007,10 +1007,20 @@ * * @param path The path of the file to write to */ - (void)writeToFile: (OFString*)path; +/*! + * @brief Writes the string into the specified file using the specified + * encoding. + * + * @param path The path of the file to write to + * @param encoding The encoding to use to write the string into the file + */ +- (void)writeToFile: (OFString*)path + encoding: (of_string_encoding_t)encoding; + #ifdef OF_HAVE_BLOCKS /*! * Enumerates all lines in the receiver using the specified block. * * @brief block The block to call for each line Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -2222,16 +2222,24 @@ return ret; } - (void)writeToFile: (OFString*)path { + return [self writeToFile: path + encoding: OF_STRING_ENCODING_UTF_8]; +} + +- (void)writeToFile: (OFString*)path + encoding: (of_string_encoding_t)encoding +{ void *pool = objc_autoreleasePoolPush(); OFFile *file; file = [OFFile fileWithPath: path mode: @"wb"]; - [file writeString: self]; + [file writeString: self + encoding: encoding]; objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_BLOCKS