Objective-C Encoding Enumerations
The constants listed in Table 2.4 are the string encodings provided by the NSString class. You’ll use these encodings for the specified operating system so that the characters being encoded have the proper, understandable codes so that they are appropriately displayed. For example, if you are exporting text from your app that you know is going to a platform that does not support Unicode, you should encode it to the ASCII format using the NSASCIIStringEncoding constant.
Table 2.4 Encoding Formats
Enum |
Name |
Value Description |
NSASCIIStringEncoding |
1 |
Supports only lower-value, 0–127, ASCII characters. No support for higher-bit characters. You’ll want to use this only if characters need to be in 7-bit ASCII. |
NSNEXTSTEPStringEncoding |
2 |
Supports encoding used by NeXT. |
NSJapaneseEUCStringEncoding |
3 |
Supports a variable-width encoding used to represent the elements of three Japanese character set standards (JIS X 0208, JIS X 0212, JIS X 0201). |
NSUTF8StringEncoding |
4 |
Allows for full Unicode support. Characters display as ASCII when the text is plain English. |
NSISOLatin1StringEncoding |
5 |
Encoding for European characters as high-bit ASCII (values 128–255). Also cross-platform international standard. Very common for Web sites to deliver their text in this format. |
NSSymbolStringEncoding |
6 |
Way for symbol characters to be encoded. |
NSNonLossyASCIIStringEncoding |
7 |
Similar to NSASCIIStringEncoding. Reinforces no high-bit characters. |
NSShiftJISStringEncoding |
8 |
Supports Shift Japanese Industrial Standards encoding. |
NSISOLatin2StringEncoding |
9 |
Supports ISO/IEC 8859 encoding of European languages. |
NSUnicodeStringEncoding |
10 |
Encodes all characters as two bytes. Marker bytes exist at the beginning of the file stream to signify whether the byte order is little or big endian. |
NSWindowsCP1251StringEncoding |
11 |
Supports Cyrillic text. This is the same as AdobeStandardCyrillic. |
NSWindowsCP1252StringEncoding |
12 |
Supports “WinLatin1” encoding. This is the most common for European/English text. Windows boxes that host Web sites deliver their context in this format. |
NSWindowsCP1253StringEncoding |
13 |
Supports “Greek” encoding. |
NSWindowsCP1254StringEncoding |
14 |
Supports “Turkish” encoding. |
NSWindowsCP1250StringEncoding |
15 |
As with Latin1, supports “WinLatin2” encoding. |
NSISO2022JPStringEncoding |
21 |
Japanese encoding for e-mail. |
NSMacOSRomanStringEncoding |
30 |
Default encoding for the Mac. |
NSUTF16StringEncoding = |
Supports UTF16. |
|
NSUnicodeStringEncoding |
NSUnicodeStringEncoding is an alias for NSUTF16qStringEncoding. |
|
NSUTF16BigEndianStringEncoding |
0x90000100 |
NSUTF16StringEncoding encoding with explicit endianness specified. |
NSUTF16LittleEndianStringEncoding |
0x94000100 |
NSUTF16StringEncoding encoding with explicit endianness specified. |
NSUTF32StringEncoding |
0x8c000100 |
Convert NSString to NSUTF32StringEncoding. |
NSUTF32BigEndianStringEncoding |
0x98000100 |
NSUTF32StringEncoding encoding with explicit endianness specified. |
NSUTF32LittleEndianStringEncoding |
0x9c000100 |
NSUTF32StringEncoding encoding with explicit endianness specified. |
NSProprietaryStringEncoding |
65536 |
As the name of the enum infers, used for custom, proprietary encodings. |