Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #161332
| From | "Morten W. Petersen" <morphex@gmail.com> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Locale-related questions |
| Date | 2015-11-29 17:40 +0100 |
| Message-ID | <qAdb4-8tm-13@gated-at.bofh.it> (permalink) |
| References | <qAamR-6K1-11@gated-at.bofh.it> <qAamR-6K1-9@gated-at.bofh.it> <qAbCh-7py-1@gated-at.bofh.it> <qAbLX-7Ij-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
Nicolas,
OK. I don't know exactly what I'm talking about here as you can see. :)
I'm writing an XML parser/writer/simple DOM, which will input and output
primarily in UTF-32.
This program outputs some information to stdout in the testing process,
and this is also UTF-32 (internally a character is an integer >= 32 bits).
I tried now to use putwchar:
putwchar((wchar_t) buffer[index]);
And the output is the same as if had used
printf("%c", (char) buffer[index]);
That is, non-ASCII characters are garbled.
All the locale settings except LC_ALL are en_US.UTF-8, LC_ALL is empty.
What I'm looking for is a cross-platform way to output some data, to aid
in the testing process. Reading and writing from files will probably be
binary and handled internally in the program.
-Morten
On Sun, Nov 29, 2015 at 4:04 PM, Nicolas George <george@nsup.org> wrote:
> Le nonidi 9 frimaire, an CCXXIV, Morten W. Petersen a écrit :
> > I was looking for a locale that would enable me to putwchar a 32-bit
> > Unicode character to stdout and have things handled correctly,
> > automatically. Without any re-encoding to UTF-8 and so on.
>
> I do not know what your program is about, but what you are asking seems to
> me like a very bad idea.
>
> You should use putwchar() if you WANT automatic recoding to the current
> locale, transparently and for any locale, as long as the character is
> possible.
>
> On the other hand, if as you say you do not want automatic recoding, then
> you should use octet-based output functions: serialize your Unicode code
> point to little or big endian as you prefer and use putchar() or fwrite()
> to
> send it.
>
> Note that wchar_t are Unicode code point under GNU but that is neither
> guaranteed nor portable. Personally, I recommend not to use wchar_t
> entirely.
>
> Regards,
>
> --
> Nicolas George
>
--
Twittering at http://twitter.com/blogologue
Blogging at http://blogologue.com
Playing music at https://soundcloud.com/morten-w-petersen
Also playing music and podcasting here:
http://www.mixcloud.com/morten-w-petersen/
On Google+ here https://plus.google.com/107781930037068750156
On Instagram at https://instagram.com/morphexx/
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Locale-related questions Alex Vong <alexvong1995@gmail.com> - 2015-11-29 14:40 +0100
Re: Locale-related questions "Morten W. Petersen" <morphex@gmail.com> - 2015-11-29 16:00 +0100
Re: Locale-related questions Nicolas George <george@nsup.org> - 2015-11-29 16:10 +0100
Re: Locale-related questions "Morten W. Petersen" <morphex@gmail.com> - 2015-11-29 17:40 +0100
Re: Locale-related questions "Thomas Schmitt" <scdbackup@gmx.net> - 2015-11-29 19:50 +0100
Re: Locale-related questions Nicolas George <george@nsup.org> - 2015-11-29 20:30 +0100
Re: Locale-related questions "Thomas Schmitt" <scdbackup@gmx.net> - 2015-11-29 20:50 +0100
Re: Locale-related questions Nicolas George <george@nsup.org> - 2015-11-29 21:00 +0100
Re: Locale-related questions Nicolas George <george@nsup.org> - 2015-11-29 21:50 +0100
Re: Locale-related questions "Thomas Schmitt" <scdbackup@gmx.net> - 2015-11-29 21:50 +0100
Re: Locale-related questions "Morten W. Petersen" <morphex@gmail.com> - 2015-12-10 08:40 +0100
Re: Locale-related questions Nicolas George <george@nsup.org> - 2015-12-10 09:00 +0100
Re: Locale-related questions "Thomas Schmitt" <scdbackup@gmx.net> - 2015-12-10 10:40 +0100
csiph-web