Printing UTF-8 in C
Dov Grobgeld
dov.grobgeld at gmail.com
Sun Jan 12 21:26:03 IST 2014
The most unixy way is to treat everything as binary UTF-8 and then forget
about encodings. The following program works just fine:
#include <stdio.h>
int main()
{
printf("Hello שלום!\n");
}
Compile with:
cc -o hello hello.c
./hello
Hello שלום!
(Though שלום is inversed in the terminal).
On Sun, Jan 12, 2014 at 9:02 PM, Baruch Siach <baruch at tkos.co.il> wrote:
> Hi Dov,
>
> On Sun, Jan 12, 2014 at 08:53:38PM +0200, Dov Grobgeld wrote:
> > Writing hebrew to the terminal is a bad idea because terminals do not
> > support BiDi reordering.
> >
> > That said, doing "cat small-hello.utf8"[1] works for me in gnome-term
> > (though it is reversed). No special environment variables were defined.
>
> But Ori has specifically asked about sending just one character to
> terminal.
> cat treats everything like binary data.
>
> baruch
>
> > On Sun, Jan 12, 2014 at 8:34 PM, Ori Idan <ori at helicontech.co.il> wrote:
> > > I need to print several Hebrew characters (UTF-8) to the terminal.
> > > My locale is set to he_IL.UTF-8 so it shows Hebrew on the terminal,
> > > however printing from C gives me Chinese characters.
> > > My question is how to print one character such as 'א' to the terminal.
> > >
> > > --
> > > Ori Idan
>
> --
> http://baruch.siach.name/blog/ ~. .~ Tk Open
> Systems
> =}------------------------------------------------ooO--U--Ooo------------{=
> - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20140112/f364aac3/attachment.html>
More information about the Linux-il
mailing list