gnokii-users
[Top][All Lists]
Advanced

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

issue with char_mbtowc/iconv


From: Raphaël Droz
Subject: issue with char_mbtowc/iconv
Date: Mon, 15 Apr 2013 15:36:15 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Trying to writephonebook with a Sagem myX-2, which correctly initialize
CSCS to UCS-2, I'm getting an issue with storing accentuated characters.
> char_mbtowc/iconv: invalid argument.

Here is the vcard:
> BEGIN:VCARD
> FN:Régine
> TEL;TYPE=PREF,VOICE:0000
> END:VCARD
Notice the "é".

Here is a transaction log:
# empty location
>  +CPBR=771
>  +CME ERROR: 22
# 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.

Then I added:
> fprintf(stderr, "==== , %s , %s, %d, %d [%s]\n", pin, pout, inlen, outlen, 
> gn_char_get_encoding());
in char_mbtowc(), just before iconv_open().


Here is the output:

# let's convert
# ... the number
> ==== , 0000 , , 1, 4 [UTF-8]
> ==== , 000 , 0, 1, 4 [UTF-8]
> ==== , 00 , 0, 1, 4 [UTF-8]
> ==== , 0 , 0, 1, 4 [UTF-8]
# ... the name
> ==== , Régine , <uninitialized garbage *char>, 1, 4 [UTF-8]
> ==== , égine , R, 1, 4 [UTF-8]
> char_mbtowc/iconv: invalid argument
# let's store converted string
> AT+CPBW=771,"0030003000300030",129,"0052"


>From a first look, inlen and outlen could be considered as correct
because using regular ascii character instead of "é" would output the
same value.

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.


What's the way to solve this correctly ?


thanks


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

* AT+CSCS="UCS2"
> AT+CSCS="UCS2" OK

$ printf Régine|iconv -f utf8 -t UCS-2|xxd -p
5200 e900 6700 6900 6e00 6500



reply via email to

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