Re: i18n programming question
nothing now.........I solve it by replace length-1 with ,
MIN( length-i+1
,MB_LEN_MAX) :)
On Mon, 17 Sep 2001 50191914@ee.cityu.edu.hk wrote:
> I write the following code to test the mbtowc function:
> #include <stdlib.h>
> #include <locale.h>
> int main(int argc,char **argv)
> {
> wchar_t pwc;
> int consumed;
> setlocale(LC_ALL,"zh_TW.Big5");
> if(argc > 1)
> {
> int length=strlen(argv[1]);
> int i=0;
> while(consumed=mbtowc(&pwc,argv[1]+i,length-i)>0)
> {
> printf("Consumed Byte %d\n",consumed);
> printf("Character : %lc\n",pwc);
> i+=consumed;
> }
> }
>
> }
>
> Here is the output:
> hingwah@hingwah:~/programming/i18n$./testcharacter 意非凡BBS
> Consumed Byte 1
> Character : 意
> Consumed Byte 1
> Character : N
> Consumed Byte 1
> Character : 非
> Consumed Byte 1
> Character : D
> Consumed Byte 1
> Character : 凡
> Consumed Byte 1
> Character : Z
> Consumed Byte 1
> Character : B
> Consumed Byte 1
> Character : B
> Consumed Byte 1
> Character : S
>
>
>
> And I want to ask isn't the mbtowc function should return 2 as it consume 2 byte
> to construct the chinese character
> --
> To UNSUBSCRIBE, email to debian-chinese-big5-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
>
--
To UNSUBSCRIBE, email to debian-chinese-big5-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
--
| This message was re-posted from debian-chinese-big5@lists.debian.org
| and converted from big5 to gb2312 by an automatic gateway.
Reply to: