[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: issue with char_mbtowc/iconv

From: Daniele Forsi
Subject: Re: issue with char_mbtowc/iconv
Date: Tue, 16 Apr 2013 19:06:43 +0200

2013/4/15 Raphaël Droz:

> # let's convert
>> char_mbtowc/iconv: Argument invalide
> # let's store converted string
>> AT+CPBW=771,"0030003000300030",129,"0052"
> 0052 is only the first "R" as the conversion failed after the first char.

I fixed this bug which could be reproduced with the fake driver from git:
echo -e "BEGIN:VCARD\r\nFN:Régine\r\nTEL;TYPE=PREF,VOICE:0000\r\nEND:VCARD\r\n"
| gnokii --phone fake --writephonebook --vcard --overwrite
can you test it?
I also added a test as testsuite/test.1.writephonebook

> Anyway I've the feeling "inlen" could be wrong when it comes to
> converting a wide input character. In UTF-8 "é" is 2 bytes large (C3A9)
> and 1 byte large in UCS-2 (E9), like it is using iso-8859-1.

you are right that the problem was "inlen" with multibyte UTF-8
because we were passing only one byte at a time, but "é" is 2 bytes
large in UCS-2 (like every character in UCS-2, that's the meaning of
"2" in the name), so "é" is 0x00 0xE9 in UCS-2BE not just 0xE9 like in

> What's the way to solve this correctly ?

I let iconv() use as many input bytes as it needs to complete one char

> Additional info:
> * AT+CSCS=?
>> +CSCS: ("IRA","GSM","PCCP437","8859-1","UCS2","HEX")
> # but this transaction seems omitted in latest git, isn't ?

no idea, but the driver is caching some values

> * AT+CSCS="UCS2"
> $ printf Régine|iconv -f utf8 -t UCS-2|xxd -p
> 5200 e900 6700 6900 6e00 6500

to get the same binary output as libgnokii you need to use UCS-2BE

Daniele Forsi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]