@@ -160,20 +160,39 @@ + (instancetype)stringWithCharacters: (const of_unichar_t*)characters length: (size_t)length byteOrder: (of_byte_order_t)byteOrder; /*! - * @brief Creates a new OFString from a big endian UTF-16 encoded string with - * the specified length. + * @brief Creates a new OFString from a UTF-16 encoded string. + * + * @param string The UTF-16 string + * @return A new autoreleased OFString + */ ++ (instancetype)stringWithUTF16String: (const uint16_t*)string; + +/*! + * @brief Creates a new OFString from a UTF-16 encoded string with the specified + * length. * * @param string The UTF-16 string * @param length The length of the unicode string * @return A new autoreleased OFString */ + (instancetype)stringWithUTF16String: (const uint16_t*)string length: (size_t)length; +/*! + * @brief Creates a new OFString from a UTF-16 encoded string, assuming the + * specified byte order if no BOM is found. + * + * @param string The UTF-16 string + * @param byteOrder The byte order to assume if there is no BOM + * @return A new autoreleased OFString + */ ++ (instancetype)stringWithUTF16String: (const uint16_t*)string + byteOrder: (of_byte_order_t)byteOrder; + /*! * @brief Creates a new OFString from a UTF-16 encoded string with the * specified length, assuming the specified byte order if no BOM is * found. * @@ -339,10 +358,18 @@ */ - initWithCharacters: (const of_unichar_t*)characters length: (size_t)length byteOrder: (of_byte_order_t)byteOrder; +/*! + * @brief Initializes an already allocated OFString with a UTF-16 string. + * + * @param string The UTF-16 string + * @return An initialized OFString + */ +- initWithUTF16String: (const uint16_t*)string; + /*! * @brief Initializes an already allocated OFString with a UTF-16 string with * the specified length. * * @param string The UTF-16 string @@ -350,10 +377,21 @@ * @return An initialized OFString */ - initWithUTF16String: (const uint16_t*)string length: (size_t)length; +/*! + * @brief Initializes an already allocated OFString with a UTF-16 string, + * assuming the specified byte order if no BOM is found. + * + * @param string The UTF-16 string + * @param byteOrder The byte order to assume if there is no BOM + * @return An initialized OFString + */ +- initWithUTF16String: (const uint16_t*)string + byteOrder: (of_byte_order_t)byteOrder; + /*! * @brief Initializes an already allocated OFString with a UTF-16 string with * the specified length, assuming the specified byte order if no BOM is * found. * @@ -900,8 +938,9 @@ #ifdef __cplusplus extern "C" { #endif extern size_t of_string_utf8_encode(of_unichar_t, char*); extern size_t of_string_utf8_decode(const char*, size_t, of_unichar_t*); +extern size_t of_string_utf16_length(const uint16_t*); #ifdef __cplusplus } #endif