"illegal character encoding in string literal" warnings in Xcode

Good day!

I have a long-term project ported all the way up from old Think C through many versions of Xcode. Its source files are encoded in "Western (Mac OS Roman)".

Some of my error messages have characters outside the straight ASCII character set (i.e. "å"). The editor correctly displays these, but I get plenty of Illegal Character warnings and the messages do not display properly.

I imagine there's a way to have seperate files of localized text for internationalized applications, but I am the only end-user of this application, and it used to just plain work in earlier Xcode versions. Furthermore, there must be developers throughout Europe who use such characters in string literals, just typing in their native languages, straight off their keyboards.

I was thinking that there must be a Clang setting or something, but have been unable to find it, and an internet search turns up no solution except to cumbersomely escape each individual character. I can't imagine that a French programmer does that every time they want to type "è", "é", or "à"!

Any help? (Disclaimer: I'm an English speaker and only use such characters whimsically, but want to keep them for legacy's sake.)

Thanks....

p.s. using Xcode 15.3, and under Settings->Text Editing->Editing, "Western (Mac OS Roman)" is already selected as the default text encoding with "Convert existing files on save" checked.

Some of my error messages have characters outside the straight ASCII character set (i.e. "å"). The editor correctly displays these, but I get plenty of Illegal Character warnings and the messages do not display properly.

Could you show related code, as well as the exact warnings and a screenshot of messages you get.

That will help understand what's happening and hopefully propose solution.

(1) Example of a line of code defining values for a drop-down menu, with warning message.

(2) How the bottom of the drop-down menu displays.

I took a brand new Xcode project in Xcode 16.4, via New Project > macOS > Command Line tool (Objective-C), and pasted in the following:

char*ppstrs[9]={"user","zero","ctr","ø∆1","ø∆2","ø∆3","†∆1","†∆2","†∆3"};

That much worked with the default UTF-8 file encoding., no complier warning about the characters. I then switched the file to Western (Mac OS Roman), and the warning status did not change.

I suspect understanding this means we need to see an exact source file and the exact bytes for each character. Are you able to post an example source file somewhere with the exact code and characters that reproduces the error?

— Ed Ford,  DTS Engineer

"illegal character encoding in string literal" warnings in Xcode
 
 
Q