@@ -40,15 +40,18 @@ /*! @file */ @class OFConstantString; -#if !defined(__cplusplus) || __cplusplus < 201103L -typedef uint_least16_t char16_t; -typedef uint_least32_t char32_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 char32_t of_unichar_t; +typedef of_char32_t of_unichar_t; /*! * @brief The encoding of a string. */ typedef enum of_string_encoding_t { @@ -262,11 +265,11 @@ * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. */ -@property (readonly, nonatomic) const char16_t *UTF16String +@property (readonly, nonatomic) const of_char16_t *UTF16String OF_RETURNS_INNER_POINTER; /*! * @brief The length of the string in UTF-16 characters. */ @@ -277,11 +280,11 @@ * * The result is valid until the autorelease pool is released. If you want to * use the result outside the scope of the current autorelease pool, you have to * copy it. */ -@property (readonly, nonatomic) const char32_t *UTF32String +@property (readonly, nonatomic) const of_char32_t *UTF32String OF_RETURNS_INNER_POINTER; /*! * @brief The string with leading whitespaces deleted. */ @@ -428,21 +431,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 char16_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 char16_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 byte order mark is found. @@ -449,11 +452,11 @@ * * @param string The UTF-16 string * @param byteOrder The byte order to assume if there is no byte order mark * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF16String: (const char16_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 byte order @@ -462,31 +465,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 byte order mark * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF16String: (const char16_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 char32_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 char32_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 byte order mark is found. @@ -493,11 +496,11 @@ * * @param string The UTF-32 string * @param byteOrder The byte order to assume if there is no byte order mark * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF32String: (const char32_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 byte order @@ -506,11 +509,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 byte order mark * @return A new autoreleased OFString */ -+ (instancetype)stringWithUTF32String: (const char32_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. @@ -696,21 +699,21 @@ * @brief Initializes an already allocated OFString with a UTF-16 string. * * @param string The UTF-16 string * @return An initialized OFString */ -- (instancetype)initWithUTF16String: (const char16_t *)string; +- (instancetype)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 */ -- (instancetype)initWithUTF16String: (const char16_t *)string +- (instancetype)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 byte order mark is found. @@ -717,11 +720,11 @@ * * @param string The UTF-16 string * @param byteOrder The byte order to assume if there is no byte order mark * @return An initialized OFString */ -- (instancetype)initWithUTF16String: (const char16_t *)string +- (instancetype)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 byte @@ -730,31 +733,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 byte order mark * @return An initialized OFString */ -- (instancetype)initWithUTF16String: (const char16_t *)string +- (instancetype)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 */ -- (instancetype)initWithUTF32String: (const char32_t *)string; +- (instancetype)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 */ -- (instancetype)initWithUTF32String: (const char32_t *)string +- (instancetype)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 byte order mark is found. @@ -761,11 +764,11 @@ * * @param string The UTF-32 string * @param byteOrder The byte order to assume if there is no byte order mark * @return An initialized OFString */ -- (instancetype)initWithUTF32String: (const char32_t *)string +- (instancetype)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 byte @@ -774,11 +777,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 byte order mark * @return An initialized OFString */ -- (instancetype)initWithUTF32String: (const char32_t *)string +- (instancetype)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. @@ -1173,11 +1176,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 char16_t *)UTF16StringWithByteOrder: (of_byte_order_t)byteOrder +- (const of_char16_t *)UTF16StringWithByteOrder: (of_byte_order_t)byteOrder OF_RETURNS_INNER_POINTER; /*! * @brief Returns the string in UTF-32 encoding with the specified byte order. * @@ -1186,11 +1189,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 char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder +- (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder OF_RETURNS_INNER_POINTER; /*! * @brief Returns the string as OFData with the specified encoding. * @@ -1248,12 +1251,12 @@ extern "C" { #endif extern of_string_encoding_t of_string_parse_encoding(OFString *); extern size_t of_string_utf8_encode(of_unichar_t, char *); extern ssize_t of_string_utf8_decode(const char *, size_t, of_unichar_t *); -extern size_t of_string_utf16_length(const char16_t *); -extern size_t of_string_utf32_length(const char32_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 OF_ASSUME_NONNULL_END