I’m a new to Obj-C (my experience is in Java and a little C)
I have this project these days, which is An Arabic-Text encryption .. I need to read an arabic text file (character by character), but when I want to use these characters and store them in variables (of type char) I couldn’t .. it gives me this warning “Multi-character character constant” on this line :
char c = ‘ب’; // here I’m trying to store the letter “Bah” in a char variable
I think it’s an encoding problem, but I don’t know what exactly the problem is, and I spent the last 2 days looking for a solution, but couldn’t find one 🙁 ..
Thanks in advance 🙂
The chracter viewer tells me your character is unicode number 0x628. It’s too big to store in a single char which is only 8 bits. The good news is that it will fit in a unichar so:
might work. But the compiler doesn’t guarantee to be able to handle characters outside a limited character set. For safety you might want to use the UTF-16 encoding explicitly (this is what NSStrings use internally. So:
Or if you prefer UTF-8, the UTF-8 encoding for that unicode number is D8 A8:
Edit:
Some ways to get the character into an NSString:
Use -stringWithFormat:
Or