@". . . " is 7-bit ASCII?


#1

Hi,

4th ed, p 47: ‘supports the @"…" construct to create a string object constant from a 7-bit ASCII encoding’. I found I can stick all kinds of Unicode chars: checkmarks, square root sign, etc, into the @"" constant and they display just fine with NSLog(). My source file is UTF-8 coded, the default in Xcode 4.2 AFAIK.

Should it read ‘from a unicode text’? Or am I using it unsafely and just getting “lucky”? Accidental and misleading “success” is bad luck in my book.

BTW, I’ve been waiting for this 4th edition for a while now (skipped 3rd ed, since 4 was looming), and am really glad it’s finally arrived! 2nd Ed was very useful back in 2007 on another project, but my knowledge all rusted out for lack of use after I finished the project, and the world has changed vastly since then, anyway.

Finally, British English being the only “My language” choice on the board is not too bad for me, a Canuck, but may be jolly restrictive for others :slight_smile:


#2

Apple’s String Programming Guide urges us to stick to 7-bit ASCII characters, but yes it does seem that in practice we can get away with almost anything. I suspect that it is indeed reliant on the character encoding of the file, although I can’t find any documentation to back this up.

Adam


#3

Thanks, Adam, guess I was just getting “lucky”. I’ll check out the API for making NSStrings in general.