utf-8 character is displayed badly in GPA interface (Win32)

Werner Koch wk at gnupg.org
Wed May 2 19:30:51 CEST 2007


On Wed,  2 May 2007 14:32, orice at secarica.ro said:

> Is there a problem with the GPA ?

Yes, it is due to this simple heuristics:

  /* Make sure the encoding is UTF-8.  Test structure suggested by
     Werner Koch.  */
  for (s = string; *s && !(*s & 0x80); s++)
    ;
  if (*s && !strchr (string, 0xc3))
    {
      /* The string is Latin-1.  */
      return  g_convert (string, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
    }
  else
    {
      /* The string is already in UTF-8.  */
      return g_strdup (string);
    }

Obviously this is not correct.  Your name is correctly utf-8 encoded as
"Cristian Secar\xc4\x83".  The above code will falsely assume that this
is Latin-1 one and converts the string to utf-8.  The code works for the
French an German characters but obviously not tested with other
character sets. 

The hack is required because PGP has a long standing bug which did not
do any conversion and stored names verbatim.  Most systems at that time
used Latin-1 so German and other folks got their Umlauts (e.g. Müller)
wrong.

The problem is that an utf-8 strings may also be a valid Latin-1
string.  Most names would look strange, though. I will change the test
to take the continuation bytes in account.


Shalom-Salam,

   Werner




More information about the Gpa-dev mailing list