Swift offers a series of encodings for strings. As of the time I'm writing this, none of them are documented, which makes this absurdly more confusing than it should be...
I can understand that .ascii
means it's ASCII encoded, .utf8
means the string is UTF-8 encoded, and .utf16BigEndian
means the string is UTF-16 but big-endian. These obviously map to real text encodings.
Then there's .unicode
. There is no "Unicode" encoding. The Unicode standard defines UTF-8, UTF-16, and UTF-32, which, as I said above, are already defined in Swift.
Is it a fancy one which figures out the best one for the system? Is it an alias for .utf8
? Is it some weird Apple Unicode encoding?
It would appear to be an alias for
.utf16
. FromCFString.h
:You can confirm this with: