[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Just a few UTF8 questions...
- From: Matthias Clasen <maclas gmx de>
- To: gtk-app-devel-list gnome org
- Subject: Re: Just a few UTF8 questions...
- Date: 09 Jul 2003 02:36:08 +0200
> Also, if I read in from a socket to a gchar buffer[1024] and I then
> proceed to print that information in the form
>
> g_message("socket input: %*s", bytes, buffer);
>
> Does the * represent how many characters or bytes that are printed from the
> buffer?
There was a thread about this in gtk-list in March:
http://mail.gnome.org/archives/gtk-list/2003-March/msg00007.html
The answers were:
a) The way GLib uses UTF-8 together with printf has the unfortunate effect
that the precision operates on bytes rather than characters.
b) Glibc has a "feature" where %Ns actually checks for a whole
number of characters in the current encoding. So, unless you
are sure you are always going to be in an UTF-8 locale, avoid
using %Ns. (You are basically OK for iso-8859-1, but will
have problems in say, a Japanese locale.)
Matthias
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]