r/cprogramming • u/Fahim_Hosain • Sep 10 '26
How to print Unicode characters in c language.
I was trying to create an encryption system that's the way i was trying to print from integer to Unicode. I can convert the integer to Unicode (hexadecimal) but i couldn't convert unicode to Unicode characters.
there are limited resources for c in these issues. If anyone knows this help me...
4
Upvotes
2
u/pjl1967 Sep 10 '26
The first thing is deciding which Unicode characters you want to convert to. The thing with Unicode is that there are multiple ways to encode a Unicode codepoint into a stream of bytes to be emitted:
Depending on what you're doing, you may need to use a library like ICU to do conversions, e.g., if you need to do complicated things like Unicode normalization, you'll probably want to use a library like ICU.
If you really just want to print stuff as-is, then you can just roll your own codepoint-to-UTF-8 converter. Here is one I wrote for my
adprogram.Note that if you want to actually see UTF-8 in a terminal like xterm, your terminal's encoding also has to be set to UTF-8, e.g.:
2
u/Big-Rub9545 Sep 10 '26
This isn’t really a C-specific thing. If you mean you want to convert unicode numeric values into unicode sequences, you can have a look at the unicode encoding scheme. It’s fairly simple and would be a nice exercise to see if you can implement it in concise way.
1
u/sciencekm Sep 11 '26
Windows:
Linux: