Re: Printing UTF-8 in C

2014-01-12 Thread Eli Zaretskii
> From: Ori Idan > Date: Sun, 12 Jan 2014 20:46:50 +0200 > > > Is the C source stored on disk in UTF-8 encoding? > > > ‎Yes but what's the difference? latin characters in UTF-8 are the same in > latin1 encoding and UTF-8 No, Latin-1 and UTF-8 encodings for Latin characters are different. You are

Re: Printing UTF-8 in C

2014-01-12 Thread Omer Zak
You may want to review the following StackOverflow item: http://stackoverflow.com/questions/4607413/c-library-to-convert-unicode-code-points-to-utf8 One answer describes how to do it yourself. Another answer uses the iconv library. On Sun, 2014-01-12 at 21:29 +0200, Ori Idan wrote: > > > > On S

Re: Printing UTF-8 in C

2014-01-12 Thread Dov Grobgeld
Create a list of all hebrew characters and dereference the list according to the index of the character. const char **alefbet = { "\327\220", "\327\221", : } printf("%s\n", alefbet[index]); // For index in 0..26 Am I missing something? Dov On Sun, Jan 12, 2014 at 9:29 PM, Ori Idan wr

Re: Printing UTF-8 in C

2014-01-12 Thread Ori Idan
On Sun, Jan 12, 2014 at 9:26 PM, Dov Grobgeld wrote: > The most unixy way is to treat everything as binary UTF-8 and then forget > about encodings. The following program works just fine: > > #include > int main() > { > printf("Hello שלום!\n"); > } > > Compile with: > > cc -o hello hello.c > ./h

Re: Printing UTF-8 in C

2014-01-12 Thread Dov Grobgeld
The most unixy way is to treat everything as binary UTF-8 and then forget about encodings. The following program works just fine: #include int main() { printf("Hello שלום!\n"); } Compile with: cc -o hello hello.c ./hello Hello שלום! (Though שלום is inversed in the terminal). On Sun, Jan

Re: Printing UTF-8 in C

2014-01-12 Thread Ori Idan
On Sun, Jan 12, 2014 at 9:02 PM, Baruch Siach 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 i

Re: Printing UTF-8 in C

2014-01-12 Thread Baruch Siach
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 vari

Re: Printing UTF-8 in C

2014-01-12 Thread Dov Grobgeld
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. Regards, Dov [1] http://paps.sourceforge.net/small-hello.ut

Re: Printing UTF-8 in C

2014-01-12 Thread Vassilii Khachaturov
On 12.01.2014 20:34, Ori Idan 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.

Re: Printing UTF-8 in C

2014-01-12 Thread Eli Zaretskii
> From: Ori Idan > Date: Sun, 12 Jan 2014 20:34:07 +0200 > > 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

Printing UTF-8 in C

2014-01-12 Thread Ori Idan
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 __