@@ -13,10 +13,12 @@ #include #import "OFObject.h" #import "OFArray.h" +extern int of_string_check_utf8(const char *str, size_t len); + /** * A class for managing strings. */ @interface OFString: OFObject { @@ -27,36 +29,37 @@ int length; #if __LP64__ int _unused; #endif #endif + BOOL is_utf8; } /** * \return A new autoreleased OFMutableString */ + string; /** - * Creates a new OFMutableString from a C string. + * Creates a new OFString from a C string. * * \param str A C string to initialize the OFMutableString with * \return A new autoreleased OFMutableString */ + stringWithCString: (const char*)str; /** - * Creates a new OFMutableString from a format C string. + * Creates a new OFString from a format C string. * See printf for the format syntax. * * \param fmt A string used as format to initialize the OFMutableString * \return A new autoreleased OFMutableString */ + stringWithFormat: (OFString*)fmt, ...; /** - * Creates a new OFMutableString from a format C string. + * Creates a new OFString from a format C string. * See printf for the format syntax. * * \param fmt A string used as format to initialize the OFMutableString * \param args The arguments used in the format string * \return A new autoreleased OFMutableString @@ -69,10 +72,38 @@ * * \return An initialized OFString */ - init; +/** + * Initializes an already allocated OFMutableString from a C string. + * + * \param str A C string to initialize the OFMutableString with + * \return An initialized OFMutableString + */ +- initWithCString: (const char*)str; + +/** + * Initializes an already allocated OFMutableString from a format C string. + * See printf for the format syntax. + * + * \param fmt A string used as format to initialize the OFMutableString + * \return An initialized OFMutableString + */ +- initWithFormat: (OFString*)fmt, ...; + +/** + * Initializes an already allocated OFMutableString from a format C string. + * See printf for the format syntax. + * + * \param fmt A string used as format to initialize the OFMutableString + * \param args The arguments used in the format string + * \return An initialized OFMutableString + */ +- initWithFormat: (OFString*)fmt + andArguments: (va_list)args; + /** * \return The OFString as a C string */ - (const char*)cString; @@ -93,11 +124,11 @@ /** * Sets the OFString to the specified OFString. * * \param str An OFString to set the OFString to. */ -- setTo: (const char*)str; +- setToCString: (const char*)str; /** * Appends another OFString to the OFString. * * \param str An OFString to append