@@ -28,11 +28,18 @@ #import "OFSerialization.h" #import "OFJSONRepresentation.h" @class OFConstantString; -typedef uint32_t of_unichar_t; +#if defined(__cplusplus) && __cplusplus >= 201103L +typedef char16_t of_char16_t; +typedef char32_t of_char32_t; +#else +typedef uint_least16_t of_char16_t; +typedef uint_least32_t of_char32_t; +#endif +typedef of_char32_t of_unichar_t; /*! * @brief The encoding of a string. */ typedef enum of_string_encoding_t { @@ -152,21 +159,21 @@ * @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; ++ (instancetype)stringWithUTF16String: (const of_char16_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 UTF-16 string * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF16String: (const uint16_t*)string ++ (instancetype)stringWithUTF16String: (const of_char16_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. @@ -173,11 +180,11 @@ * * @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 ++ (instancetype)stringWithUTF16String: (const of_char16_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 @@ -186,31 +193,31 @@ * @param string The UTF-16 string * @param length The length of 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 ++ (instancetype)stringWithUTF16String: (const of_char16_t*)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder; /*! * @brief Creates a new OFString from a UTF-32 encoded string. * * @param string The UTF-32 string * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF32String: (const uint32_t*)string; ++ (instancetype)stringWithUTF32String: (const of_char32_t*)string; /*! * @brief Creates a new OFString from a UTF-32 encoded string with the * specified length. * * @param string The UTF-32 string * @param length The length of the UTF-32 string * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF32String: (const uint32_t*)string ++ (instancetype)stringWithUTF32String: (const of_char32_t*)string length: (size_t)length; /*! * @brief Creates a new OFString from a UTF-32 encoded string, assuming the * specified byte order if no BOM is found. @@ -217,11 +224,11 @@ * * @param string The UTF-32 string * @param byteOrder The byte order to assume if there is no BOM * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF32String: (const uint32_t*)string ++ (instancetype)stringWithUTF32String: (const of_char32_t*)string byteOrder: (of_byte_order_t)byteOrder; /*! * @brief Creates a new OFString from a UTF-32 encoded string with the * specified length, assuming the specified byte order if no BOM is @@ -230,11 +237,11 @@ * @param string The UTF-32 string * @param length The length of the UTF-32 string * @param byteOrder The byte order to assume if there is no BOM * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF32String: (const uint32_t*)string ++ (instancetype)stringWithUTF32String: (const of_char32_t*)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder; /*! * @brief Creates a new OFString from a format string. @@ -381,21 +388,21 @@ * @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; +- initWithUTF16String: (const of_char16_t*)string; /*! * @brief Initializes an already allocated OFString with a UTF-16 string with * the specified length. * * @param string The UTF-16 string * @param length The length of the UTF-16 string * @return An initialized OFString */ -- initWithUTF16String: (const uint16_t*)string +- initWithUTF16String: (const of_char16_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. @@ -402,11 +409,11 @@ * * @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 +- initWithUTF16String: (const of_char16_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 @@ -415,31 +422,31 @@ * @param string The UTF-16 string * @param length The length of 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 +- initWithUTF16String: (const of_char16_t*)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder; /*! * @brief Initializes an already allocated OFString with a UTF-32 string. * * @param string The UTF-32 string * @return An initialized OFString */ -- initWithUTF32String: (const uint32_t*)string; +- initWithUTF32String: (const of_char32_t*)string; /*! * @brief Initializes an already allocated OFString with a UTF-32 string with * the specified length * * @param string The UTF-32 string * @param length The length of the UTF-32 string * @return An initialized OFString */ -- initWithUTF32String: (const uint32_t*)string +- initWithUTF32String: (const of_char32_t*)string length: (size_t)length; /*! * @brief Initializes an already allocated OFString with a UTF-32 string, * assuming the specified byte order if no BOM is found. @@ -446,11 +453,11 @@ * * @param string The UTF-32 string * @param byteOrder The byte order to assume if there is no BOM * @return An initialized OFString */ -- initWithUTF32String: (const uint32_t*)string +- initWithUTF32String: (const of_char32_t*)string byteOrder: (of_byte_order_t)byteOrder; /*! * @brief Initializes an already allocated OFString with a UTF-32 string with * the specified length, assuming the specified byte order if no BOM is @@ -459,11 +466,11 @@ * @param string The UTF-32 string * @param length The length of the UTF-32 string * @param byteOrder The byte order to assume if there is no BOM * @return An initialized OFString */ -- initWithUTF32String: (const uint32_t*)string +- initWithUTF32String: (const of_char32_t*)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder; /*! * @brief Initializes an already allocated OFString with a format string. @@ -947,11 +954,11 @@ * use the result outside the scope of the current autorelease pool, you have to * copy it. * * @return The string in UTF-16 encoding with native byte order */ -- (const uint16_t*)UTF16String OF_RETURNS_INNER_POINTER; +- (const of_char16_t*)UTF16String OF_RETURNS_INNER_POINTER; /*! * @brief Returns the string in UTF-16 encoding with the specified byte order. * * The result is valid until the autorelease pool is released. If you want to @@ -959,11 +966,11 @@ * copy it. * * @param byteOrder The byte order for the UTF-16 encoding * @return The string in UTF-16 encoding with the specified byte order */ -- (const uint16_t*)UTF16StringWithByteOrder: (of_byte_order_t)byteOrder +- (const of_char16_t*)UTF16StringWithByteOrder: (of_byte_order_t)byteOrder OF_RETURNS_INNER_POINTER; /*! * @brief Returns the length of the string in UTF-16 characters. * @@ -978,11 +985,11 @@ * use the result outside the scope of the current autorelease pool, you have to * copy it. * * @return The string in UTF-32 encoding with native byte order */ -- (const of_unichar_t*)UTF32String OF_RETURNS_INNER_POINTER; +- (const of_char32_t*)UTF32String OF_RETURNS_INNER_POINTER; /*! * @brief Returns the string in UTF-32 encoding with the specified byte order. * * The result is valid until the autorelease pool is released. If you want to @@ -990,11 +997,11 @@ * copy it. * * @param byteOrder The byte order for the UTF-32 encoding * @return The string in UTF-32 encoding with the specified byte order */ -- (const of_unichar_t*)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder +- (const of_char32_t*)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder OF_RETURNS_INNER_POINTER; /*! * @brief Writes the string into the specified file using UTF-8 encoding. * @@ -1029,10 +1036,10 @@ #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*); -extern size_t of_string_utf32_length(const uint32_t*); +extern size_t of_string_utf16_length(const of_char16_t*); +extern size_t of_string_utf32_length(const of_char32_t*); #ifdef __cplusplus } #endif