I got a string in little endian that I would like to convert in big endian.
This "647b" should become "7b64". How can I do this in iOS (C++ code welcome)?
PS: I am deriving the string from a NSData object.
I got a string in little endian that I would like to convert in big endian.
This "647b" should become "7b64". How can I do this in iOS (C++ code welcome)?
PS: I am deriving the string from a NSData object.
You didn't say how you were converting your data into a NSString, so I have to make some assumptions here.
NSStrings (and CFStringRefs, which are toll free bridged) have encodings. Many iOS devs don't need to keep in mind that their strings are UTF8Encoded.
[If you look at the list of string encodings from Apple (CoreFoundation & Foundation), you'll see some of them do specify little-endian and big-endian.
And probably the best way to do what you are trying to do is something like this:
// load it as UTF16 big endian
NSString *str = [NSString alloc] initWithData:yourDataObject encoding:NSUTF16BigEndianStringEncoding];