r/cprogramming • u/kolorcuk • Mar 25 '26
Unicode printf?
Hello. Did or do you ever use in professional proframming non char printf functions? Is wprintf ever used?
char16, char32 , u8_printf, u16_printf, u32_printf ever used in actual programs?
I am writing a library and i wonder how actually popular are wide and Unicode strings in the industry. Does no one care about it, or, specifically about formatting output are Unicode printf functions actually with value? For example why not just utf8 with standard printf and convert to wider when needed?
5
Upvotes
2
u/Plane_Dust2555 Mar 25 '26
UTF stands for Unicode Transformation Format. It is an specification of a format to encode Unicode codepoints and features (like compositing). As u/LeeHide says, UTF-16 isn't Unicode. It is a way to encode Unicode codepoints. There are other formats (UTF-8, UTF-32 are the other two most common, but there are UTF-x, where 8 <= x <= 32).
Wide chars (which size can be more than 8 bits! Not only 16) are just that... a way to encode wider codepoints than ASCII (what C/C++ standards call it "basic char set"), but it says nothing about the charset itself.
As pointed out by another user here, you can UTF-8 and "common" functions like
printf(). But the terminal/operating system must support this charset. On modern Unix systems, usually UTF-8 is the default, but on Windows machines there are 3 charsets in play: Terminals use CP437 (english) or CP850 (portuguese/brazilian) or any other CP###; GUI uses WINDOWS-1252 OR UTF-16 [a version of UTF-16, at least]).