How do I avoid the Unicode character in Objective-C source code?
I feel incredibly stupid to ask this, but the docs and google give me no love.
I have a Unicode character that I want to insert into a string literal in the source code of my iPhone application. I know its hexadecimal value. What's the correct escape sequence to use? And for that matter, what obvious source of information am I missing, what would tell me about this?
a source to share
A more modern approach:
I'm not sure when this feature was added to the language, but as of 2015, at least Objective-C string literals can contain any Unicode character. For example, I mark my line log with emoji because their distinctive colors are an easier way to select them:
So, if you have a character, not just code, and you want to use it in a static string rather than dynamically generating it, this is a great approach, since you immediately know which character you are using by looking at it.
a source to share
The correct escape sequence would be something like strings
wchar_t * str = L"\x0627";
See this question: character constant: \ 000 \ xhh
Edit: Oh sorry, I missed the iPhone and Objective-C tags. The above is for general C / C ++, but I have not worked with iPhone development, so your mileage may vary.
a source to share
