How do I get the bytes length of NSString
? if myString
contains \"hallo\", myString.length
will return 5, but how many actual bytes are ta
From the Apple documentation:
An NSString object encodes a Unicode-compliant text string, represented as a sequence of UTF–16 code units. All lengths, character indexes, and ranges are expressed in terms of 16-bit platform-endian values, with index values starting at 0.
So the memory used by an NSString is 2 bytes per character plus whatever fixed memory is used by the object itself.