ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
UTF-8 supports 7-bit ASCII but it also supports much more than that.
<= This is absolutely true
I didn't want to overcomplicate things in my reply - but I hope I didn't oversimplify them, either (at least not too much ).
I want to emphasize - for the majority of string handling you're likely to do in C (and certainly for things like 8-bit '\n' and '\t' characters), you can essentially say "the standard C library gives you UTF-8 for free". Because the majority of string handling in most "classic" C programs *IS* 7-bit ASCII.
Please follow up on some of the links provided. They're all good. I'd especially recommend this one:
You're already going UTF-8. That's definitely the right thing to do, and apologies again for confusing things. Here's a quote from the above link emphasizing this point:
The best advice you can get is to steer clear of wide characters.
You should never need to use any wide character functions.
Keep the data in your program internally represented as utf-8.
The standard byte-oriented "strlen", "strcpy", "strstr", "printf" etc
work fine with utf-8.
XML uses utf-8 by default as well, so little if any conversion between
encodings should be needed. You may have to convert your input from a
legacy encoding to utf-8, or you could just externally convert using
something such as this: