Currently, I'm trying to parse an NSData
in my iOS app. Problem is, I can't seem to find a proper hebrew encoding for parsing. I must decode the data using the Windows-1255
encoding (hebrew encoding type for windows) or ISO 8859-8
encoding, or I'll get plain gibberish. The closest I've got to solving the issue was using
CFStringConvertEncodingToNSStringEncoding(CFStringEncodings.ISOLatinHebrew)
yet it throws 'CFStringEncodings' is not convertible to 'CFStringEncoding'
(notice Encodings vs Encoding).
What can I do in order to encode the data correctly?
Thanks!
The problem is that
CFStringEncodings
is an enumeration based onCFIndex
(which in turn is a type alias forInt
), whereasCFStringEncoding
is a type alias forUInt32
. Therefore you have to convert the.ISOLatinHebrew
value explicitly to aCFStringEncoding
:Turns out I needed to get my hands a bit dirty. I saw that
CFStringEncodings
has a relation to the fileCFStringEncodingsExt.h
, so I searched the file for some help. Suddenly I came across a hugeCF_ENUM
that included exactly what I needed- all of theCFStringEncodings
by theirUInt32
value!So it has turned out that
kCFStringEncodingISOLatinHebrew = 0x0208, /* ISO 8859-8 */
I encourage everyone who is facing this encoding issue to go to that file and search for his needed encoding.