Mailing List Archive

utf-8 character is displayed badly in GPA interface (Win32)
The GPA interface displays badly the utf-8 component from my name.
This is how it looks like:
http://www.secarica.ro/misc/gpa_bad_utf8_display_noted.png

It does not matter if the key is generated using the gpg --key-gen
command, or via GPA interface. However, the gpg --list-keys displays
correctly the ã character.

Is there a problem with the GPA ?
I am using the precompiled version included in gpg4win package. The
system is set to Romanian locale.
At the same time, all Romanian characters included in the interface are
being displayed well, except a (known) issue with the toolbar title in
GTK+ for Win32 version, where a Unicode character that does not exist in
any CP-12xx makes the toolbar tile to appear blank.

Cristi

_______________________________________________
Gpa-dev mailing list
Gpa-dev@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gpa-dev
Re: utf-8 character is displayed badly in GPA interface (Win32) [ In reply to ]
Hi Cristian,

On Wednesday 02 May 2007 14:32, Cristian Secarã wrote:
> The GPA interface displays badly the utf-8 component from my name.
> This is how it looks like:
> http://www.secarica.ro/misc/gpa_bad_utf8_display_noted.png
>
> It does not matter if the key is generated using the gpg --key-gen
> command, or via GPA interface. However, the gpg --list-keys displays
> correctly the ã character.
>
> Is there a problem with the GPA ?

it seems like it, though it could also be a problem of gpg itself.

> I am using the precompiled version included in gpg4win package. The
> system is set to Romanian locale.
> At the same time, all Romanian characters included in the interface are
> being displayed well, except a (known) issue with the toolbar title in
> GTK+ for Win32 version, where a Unicode character that does not exist in
> any CP-12xx makes the toolbar tile to appear blank.

Thanks for the good problem report,
can you check
https://bugs.g10code.com/gnupg/issue?%40search_text=&title=&%40columns=title&category=6&version=&topic=&id=&%40columns=id&creation=&duedate=&activity=&%40columns=activity&%40sort=activity&priority=&%40group=priority&status=&%40columns=status&%40sortdir=on&%40action=search
and add your information, that is most convenient for developers.

Thanks,
Bernhard
--
Managing Director - Owner: www.intevation.net (Free Software Company)
Germany Coordinator: fsfeurope.org. Coordinator: www.Kolab-Konsortium.com.
Intevation GmbH, Osnabrück, DE; Amtsgericht Osnabrück, HRB 18998
Geschäftsführer Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
Re: utf-8 character is displayed badly in GPA interface (Win32) [ In reply to ]
On Wed, 2 May 2007 14:32, orice@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


_______________________________________________
Gpa-dev mailing list
Gpa-dev@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gpa-dev
Re: utf-8 character is displayed badly in GPA interface (Win32) [ In reply to ]
Hi!

Please try the SVN version of GPA or use the patch below.


Salam-Shalom,

Werner


--- src/gpgmetools.c (revision 774)
+++ src/gpgmetools.c (working copy)
@@ -729,24 +729,41 @@
static gchar *
string_to_utf8 (const gchar *string)
{
- const gchar *s;
-
+ const char *s;
+
if (!string)
- {
- return NULL;
- }
- /* Make sure the encoding is UTF-8. Test structure suggested by
- Werner Koch. */
+ return NULL;
+
+ /* Due to a bug in old and not so old PGP versions user IDs have
+ been copied verbatim into the key. Thus many users with Umlauts
+ et al. in their name will see their names garbled. Although this
+ is not an issue for me (;-)), I have a couple of friends with
+ Umlauts in their name, so let's try to make their life easier by
+ detecting invalid encodings and convert that to Latin-1. */
for (s = string; *s && !(*s & 0x80); s++)
;
- if (*s && !strchr (string, 0xc3))
+ if (*s && ((s[1] & 0xc0) == 0x80) && ( ((*s & 0xe0) == 0xc0)
+ || ((*s & 0xf0) == 0xe0)
+ || ((*s & 0xf8) == 0xf0)
+ || ((*s & 0xfc) == 0xf8)
+ || ((*s & 0xfe) == 0xfc)) )
+ {
+ /* Possible utf-8 character followed by continuation byte.
+ Although this might still be Latin-1 we better assume that it
+ is valid utf-8. */
+ return g_strdup (string);
+ }
+ else if (*s && !strchr (string, 0xc3))
{
- /* The string is Latin-1. */
- return g_convert (string, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+ /* No 0xC3 character in the string; assume that it is Latin-1. */
+ return g_convert (string, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
}
else
{
- /* The string is already in UTF-8. */
+ /* Everything else is assumed to be UTF-8. We do this even that
+ we know the encoding is not valid. However as we only test
+ the first non-ascii character, valid encodings might
+ follow. */
return g_strdup (string);
}
}



_______________________________________________
Gpa-dev mailing list
Gpa-dev@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gpa-dev
Re: utf-8 character is displayed badly in GPA interface (Win32) [ In reply to ]
On Wed, 02 May 2007 21:07:01 +0200, Werner Koch wrote:

> Please try the SVN version of GPA or use the patch below.

Thank you, I will try to do so, except that I don't know how quick that
will be.
I will post the result on this list. I will also make some other
experiments with random common person names from my language that
contains language specific characters.

Cristi

_______________________________________________
Gpa-dev mailing list
Gpa-dev@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gpa-dev