Hacker News new | past | comments | ask | show | jobs | submit login

If you're going for safety, you should check to make sure that the string can use the particular encoding, rather than assuming that it will work. CFStringIsEncodingAvailable() will do that for you :)



no. CFStringIsEncodingAvailable() tells you whether a particular encoding is available on THE CURRENT COMPUTER, not for the given string.

i brought up the CFStringGetCStringPtr() issue because my experience is that it works okay if you're using nothing but plain ascii for inputs and outputs, but tends to fail when anything more esoteric is involved. it is not just a theoretical concern, it has happened to me in the wild, with paying customers involved. on the other hand, i think it's reasonable to assume that every mac in existence will be able to handle UTF8.

this episode is reminding me that far too many programmers assume ascii everywhere. be nice to foreigners, folks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: