Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -115,11 +115,11 @@ * \return A new autoreleased OFString */ + stringWithString: (OFString*)str; /** - * Creates a new OFString with the contents of the specified file. + * Creates a new OFString with the contents of the specified UTF-8 encoded file. * * \param path The path to the file * \return A new autoreleased OFString */ + stringWithContentsOfFile: (OFString*)path; @@ -364,13 +364,20 @@ * OFInvalidEncoding exception if the string contains any non-number characters. * * \return An OFNumber */ - (uintmax_t)hexadecimalValueAsInteger; + +/** + * Writes the string into the specified file using UTF-8 encoding. + * + * \param path The path of the file to write to + */ +- (void)writeToFile: (OFString*)path; @end #import "OFConstString.h" #import "OFMutableString.h" #import "OFString+Hashing.h" #import "OFString+URLEncoding.h" #import "OFString+XMLEscaping.h" #import "OFString+XMLUnescaping.h" Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -1024,6 +1024,18 @@ num = newnum; } return num; } + +- (void)writeToFile: (OFString*)path +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + OFFile *file; + + file = [OFFile fileWithPath: path + mode: @"wb"]; + [file writeString: self]; + + [pool release]; +} @end