Re: Just a few UTF8 questions...



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]