On Sat, 2003-03-01 at 13:20, Ulf Karlsson wrote: > Hi, > > I'm trying to print strings containing swedish characters in columns > by doing > > g_print("%-16s%-16s\n", "Hallå", "Världen"); > > The problem seems to be that vasprintf isn't UTF-8-aware and counts > the swedish UTF-8 character as two characters and thus only adds 10 > whitespaces after the first string, with the consequence that the > second string is one position left of where it is supposed to be!
Notes here: - 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.) - If you want a certain number of columns, than neither number of characters or number of bytes works. A rough approximation is that if g_unichar_iswide(ch) is TRUE, then the character takes two columns, otherwise it takes one. You'll probably want to write a function that takes a string and pads/chops it to fit in a certain number of columns. Regards, Owen _______________________________________________ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list