i18n bug?

Thiago Macieira thiago at kde.org
Mon Jul 11 15:56:00 BST 2005


David Faure wrote:
>in gettext-0.10.35 (and in kdecore/libintl.cpp), the hash_string
> function is defined as hval += (unsigned long) *str++;
>
>in gettext-0.14.x, the hash_string function is defined as
>  hval += (unsigned char) *str++;
>
>I'm not sure why it makes a difference, but with msgid=áà (in utf8, so
> length=4), the hash value is 267522336 with the first line, and 843216
> with the second line.

The problem is char's signedness:

$ echo áà | od -tx1
0000000 c3 a1 c3 a0 0a

(gdb) p/x (unsigned long)(char)0xC3
$5 = 0xffffffc3
(gdb) p/x (unsigned char)(char)0xC3
$6 = 0xc3

On the first, signed 0xC3 is sign-extended to 32 bits; on the second, it's 
zero-extended (there's an implicit promotion to unsigned long on the 
second, after being cast to unsigned char).

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

1. On frumscafte, hwonne time_t wæs náht, se scieppend þone circolwyrde 
wundorcræftlíge cennede and seo eorðe wæs idel and hit wæs gód.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050711/bf1c963e/attachment.sig>


More information about the kde-core-devel mailing list