How to print unicode characters (no library)?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Dec 27 15:26:16 UTC 2021


On Mon, Dec 27, 2021 at 02:30:55PM +0000, Adam D Ruppe via Digitalmars-d-learn wrote:
> On Monday, 27 December 2021 at 11:21:54 UTC, rempas wrote:
> > So should I just use UTF-8 only for Linux?
> 
> Most unix things do utf-8 more often than not, but technically you are
> supposed to check the locale and change the terminal settings to do it
> right.

Technically, yes. But practically all modern Linux distros have
standardized on UTF-8, and you're quite unlikely to run into non-UTF-8
environments except on legacy systems or extremely specialized
applications.  I don't know what's the situation on BSD, but I'd imagine
it's pretty similar.  A lot of modern Linux applications don't even work
properly under anything non-UTF-8, so for practical purposes I'd say
don't even worry about it, unless you're specifically targeting a
non-UTF8 environment for a specific reason.


> > But what about Windows?
> 
> You should ALWAYS use the -W suffix functions on Windows when
> available, and pass them utf-16 encoded strings.
[...]

I'm not a regular Windows user, but I did remember running into problems
where sometimes command.exe doesn't handle Unicode properly, and needs
an API call to switch it to UTF mode or something.


T

-- 
First Rule of History: History doesn't repeat itself -- historians merely repeat each other.


More information about the Digitalmars-d-learn mailing list