gnokii-users
[Top][All Lists]
Advanced

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

Re: Unicode changes in CVS. Please test.


From: Shun-Jee Liu
Subject: Re: Unicode changes in CVS. Please test.
Date: Sun, 29 Sep 2002 18:54:49 +0800
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0

I am not sure what's wrong. I send the big5 (chinese) encoded satrings by gnokii --sendsms. If the first character of the SMS string is an english character (A-Z), then the message displayed in cellular phone is correct. If the first character is chinese character, space or !, ..., then some
portion of the data is corrupted.

Hu Gang wrote:

On Fri, 27 Sep 2002 16:48:58 +0200
Markus Plail <address@hidden> wrote:

Yes, It works.
But have two problem: first: The char_encode_ucs2/char_decode_ucs2 not works correctly. try my test app. other: The xxxx_ucs2 and xxx_unicode not share the xxxx_uni_alphabet function.

Please try my new patch and new test program.

---
                - Hu Gang
------------------------------------------------------------------------

#include <stdio.h>
#include <locale.h>

/* to build */
/* gcc -o tst_unicode -L /home/hugang/deve/cvs/internet/gnokii/common/ \
* -lgnokii **/

/* interface to call gnokii lib */
extern void char_encode_unicode(unsigned char *, const unsigned char *, int);
extern void char_decode_unicode(unsigned char *, const unsigned char *, int);
extern void char_decode_ucs2(unsigned char* , const unsigned char* , int);
extern void char_encode_ucs2(unsigned char* , const unsigned char* , int);

const unsigned char *cin = "?12?15";
/* feff 4f60 0031 0032 597d 0031 0035 000a * unicode of it */
const int  clen = 12;

/* copy from address@hidden@myGnokii */
void dump_string(const char *message, int messagesize)
{
       int i;
       char buf[17];

       buf[16] = 0;

       for (i = 0; i < messagesize; i++) {
               if (i % 16 == 0) {
                       if (i != 0) printf(" %s", buf);
                       printf("\n");
                       memset(buf, ' ', 16);
               } else {
                       printf("|");
               }
               printf("%02x", message[i] & 0xff);
               if (isprint(message[i]) && message[i]!=0x09) {
                       if ((i+1) % 16 != 0) printf("%c", message[i]);
                       buf[i % 16] = message[i];
               } else {
                       if ((i+1) % 16 != 0) printf(" ");
                       buf[i % 16] = '.';
               }
       }
       if (i % 16 == 0) {
               printf(" %s", buf);
       } else {
               printf("%*s %s", 4 * (16 - i % 16) - 1, "", buf);
       }
       printf("\n");

}

void do_test()
{
unsigned char u_dest[512]; unsigned char m_dest[512];

        /* dump the old string */
        dump_string(cin, clen);
        
        /* convert it to unicode */
        memset(u_dest, 0, 512);
        char_encode_unicode(u_dest, cin, clen);
        dump_string(u_dest, clen * 2);

        /* conver the unicode to old*/
        memset(m_dest, 0, 512);
        char_decode_unicode(m_dest, u_dest, clen);
        dump_string(m_dest, clen);

        /* convert it to unicode */
        memset(u_dest, 0, 512);
        char_encode_ucs2(u_dest, cin, clen);
        dump_string(u_dest, clen * 4);

        /* conver the unicode to old*/
        memset(m_dest, 0, 512);
        char_decode_ucs2(m_dest, u_dest, clen);
        dump_string(m_dest, clen);
}


int main()
{
        setlocale(LC_ALL, "");
        do_test();
}






reply via email to

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