gnokii-users
[Top][All Lists]
Advanced

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

Re: Unicode support


From: Hu Gang
Subject: Re: Unicode support
Date: Fri, 27 Sep 2002 17:44:29 +0800

On Fri, 27 Sep 2002 09:07:59 +0200 (CEST)
Pawel Kot <address@hidden> wrote:
|The same note:
|+               case 2: /* the value is multi byte
|+                        * so can check the before character */
|+                       if ( *(dest - 1) == '?' ) {
|+                               *(dest - 1) = *dest;
|+                               *(dest)     = *(dest + 1);
|+                               return 1;
|+                       }
|
|I think I don't get it. Why do we even touch *(dest-1)? It may be outside
|our process address space. My understanding of the wctomb is that we give
|it some encoded wide character. And we get the string that may be 1
|character long, 2 characters long, up to MB_CUR_MAX characters long.
|So we store it in the dest. And move the pointer the length - 1 bytes, as
|the loop iteration will move it one byte further.
Yes, But in the function, the character is one by one pass to wctomb, So the 
first multibyte can not get an value. So I do *(dest-1). It is not good idle.


|So the question: why do we even bother with '2' value? I think we don't
|need to do this at all. But I just woke up, care to enlighten me what do
|I miss?

Now, I remove it. 

Here is a new solution for all.. Please read and test it.
With an new test program for it.

test logs for new solution 

$ ./tst_unicode 
c4 |e3 |311|322|ba |c3 |311|355|00 |00 |00 |00                 ..12..15....    

4fO|60`|00 |311|00 |322|59Y|7d}|00 |311|00 |355|00 |00 |00 |00 O`.1.2Y}.1.5....
00 |00 |00 |00 |00 |00 |00 |00                                 ........        

c4 |e3 |311|322|ba |c3 |311|355|00 |00 |00 |00                 ..12..15....    

344|66f|366|300|333|311|00 |00 |333|322|00 |00 |355|399|377|64 4f6031..32..597d
333|311|00 |00 |333|355|00 |00 |300|00 |00 |00 |300|00 |00 |00 31..35..0...0...
300|00 |00 |00 |300|00 |00 |00 |00 |00 |00 |00 |00 |00 |00 |00 0...0...........

c4 |e3 |311|322|ba |c3 |311|355|00 |00 |00 |00                 ..12..15....   
-- 
                - Hu Gang

Attachment: fix_all
Description: Binary data

Attachment: tst_unicode.c
Description: Text Data

Attachment: pgpZtdNxRLaZ8.pgp
Description: PGP signature


reply via email to

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