Differences From Artifact [31ec44e41b]:
- File
src/OFString.h
— part of check-in
[9d3cd5e5fe]
at
2013-01-07 22:07:58
on branch trunk
— OFString: Zero-terminate UTF-16 strings.
This partly reverts e8502c7.
The rationale behind this is that, on some OSes, native APIs (on e.g.
Windows) take UTF-16 strings that are zero-terminated.However, forcing zero-termination for every string so that -[characters]
returns a zero-terminated UTF-32 string does not make sense. Therefore,
in the future, -[UTF32String] will be added, which will include
zero-termination. OFString subclasses can then just return their
internal representation if it includes a terminating zero or create a
copy that has a terminating zero if not. (user: js, size: 28671) [annotate] [blame] [check-ins using]
To Artifact [4892881708]:
- File src/OFString.h — part of check-in [7cddd5f891] at 2013-01-08 12:33:53 on branch trunk — OFString: Add methods for UTF-32. (user: js, size: 30778) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
201 202 203 204 205 206 207 208 209 210 211 212 213 214 | * @param byteOrder The byte order to assume if there is no BOM * @return A new autoreleased OFString */ + (instancetype)stringWithUTF16String: (const uint16_t*)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder; /*! * @brief Creates a new OFString from a format string. * * See printf for the format syntax. As an addition, %@ is available as format * specifier for objects. * * @param format A string used as format to initialize the OFString | > > > > > > > > > > > > > > > > > > > | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | * @param byteOrder The byte order to assume if there is no BOM * @return A new autoreleased OFString */ + (instancetype)stringWithUTF16String: (const uint16_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; /*! * @brief Creates a new OFString from a UTF-32 encoded string, assuming the * specified byte order if no BOM is found. * * @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 byteOrder: (of_byte_order_t)byteOrder; /*! * @brief Creates a new OFString from a format string. * * See printf for the format syntax. As an addition, %@ is available as format * specifier for objects. * * @param format A string used as format to initialize the OFString |
︙ | ︙ | |||
400 401 402 403 404 405 406 407 408 409 410 411 412 413 | * @param byteOrder The byte order to assume if there is no BOM * @return An initialized OFString */ - initWithUTF16String: (const uint16_t*)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder; /*! * @brief Initializes an already allocated OFString with a format string. * * See printf for the format syntax. As an addition, %@ is available as format * specifier for objects. * * @param format A string used as format to initialize the OFString | > > > > > > > > > > > > > > > > > > > | 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | * @param byteOrder The byte order to assume if there is no BOM * @return An initialized OFString */ - initWithUTF16String: (const uint16_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; /*! * @brief Initializes an already allocated OFString with a UTF-32 string, * assuming the specified byte order if no BOM is found. * * @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 byteOrder: (of_byte_order_t)byteOrder; /*! * @brief Initializes an already allocated OFString with a format string. * * See printf for the format syntax. As an addition, %@ is available as format * specifier for objects. * * @param format A string used as format to initialize the OFString |
︙ | ︙ | |||
900 901 902 903 904 905 906 907 908 909 910 911 912 913 | /*! * @brief Returns the length of the string in UTF-16 characters. * * @return The length of string in UTF-16 characters */ - (size_t)UTF16StringLength; /*! * @brief 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; | > > > > > > > > > > > > > > > > > > > > > > > > | 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 | /*! * @brief Returns the length of the string in UTF-16 characters. * * @return The length of string in UTF-16 characters */ - (size_t)UTF16StringLength; /*! * @brief Returns the string in UTF-32 encoding with native byte order. * * 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. * * @return The string in UTF-32 encoding with native byte order */ - (const of_unichar_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 * use the result outside the scope of the current autorelease pool, you have to * 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 OF_RETURNS_INNER_POINTER; /*! * @brief 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; |
︙ | ︙ | |||
937 938 939 940 941 942 943 944 945 946 | #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 | > | 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 | #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*); #ifdef __cplusplus } #endif |