gnokii-users
[Top][All Lists]
Advanced

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

Re: [Patch] unicode work with gnokii.


From: Hu Gang
Subject: Re: [Patch] unicode work with gnokii.
Date: Fri, 24 May 2002 12:32:28 +0800

hi: all

Here is the patch for gnokii, without need wchat.h. Please test it.
? Makefile.global
? config.cache
? config.log
? config.status
? configure
? common/gsm-sms.c.u
? include/config.h
? include/config.h.in
? packaging/RedHat/gnokii.spec
? packaging/Slackware/SlackBuild
? po/Makefile
? po/Makefile.in
? po/gnokii.pot
Index: common/gsm-encoding.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-encoding.c,v
retrieving revision 1.19
diff -u -r1.19 gsm-encoding.c
--- common/gsm-encoding.c       18 Apr 2002 21:22:50 -0000      1.19
+++ common/gsm-encoding.c       24 May 2002 04:24:55 -0000
@@ -252,30 +252,49 @@
        return;
 }
 
-void DecodeUnicode(unsigned char* dest, const unsigned char* src, int len)
+int  DecodeUnicode(unsigned char* dest, const unsigned char* src, int len)
 {
        int i;
-       wchar_t wc;
+       unsigned char * d = dest;
 
-       for (i = 0; i < len; i++) {
-               wc = src[(2 * i) + 1] | (src[2 * i] << 8);
-               dest[i] = DecodeWithUnicodeAlphabet(wc);
+       for (i = 0; i < len; ) {
+               switch (wctomb ( d + i, (*(src + i) << 8 | * (src +i + 1 )))){
+               case 2:         /* mulit char  */
+                       i += 2;
+                       break;
+               default:        /* pass the old char */
+                       *(d + i) = *(src + i + 1);
+                       d--;
+                       i += 2;
+                       break;
+               }
        }
-       dest[len] = 0;
-       return;
+       return ((d - dest) + len);
 }
 
-void EncodeUnicode(unsigned char* dest, const unsigned char* src, int len)
+int  EncodeUnicode(unsigned char* dest, const unsigned char* src, int len)
 {
        int i;
-       wchar_t wc;
+       unsigned char * d = dest;
 
-       for (i = 0; i < len; i++) {
-               wc = EncodeWithUnicodeAlphabet(src[i]);
-               dest[i*2] = (wc >> 8) & 0xff;
-               dest[(i*2)+1] = wc & 0xff;
-       }
-       return;
+       for (i = 0; i < len; ) {
+               wchar_t   wc;
+               
+               switch (mbtowc (&wc, src + i, 2)){
+               case 2:         /* mulit char  */
+                       *(d + i)     =  wc >> 8 & 0xFF;
+                       *(d + i + 1) =  wc & 0xFF;
+                       i += 2;
+                       break;
+               case 1:         /* ASCII char */
+                       *(d + i) = 0;
+                       d ++;
+               default:        /* pass old char */
+                       d[i] = *(src + i);
+                       i += 1;
+               }
+        }
+       return ( (d - dest ) + len);
 }
 
 /* Conversion bin -> hex and hex -> bin */
Index: common/gsm-sms.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-sms.c,v
retrieving revision 1.69
diff -u -r1.69 gsm-sms.c
--- common/gsm-sms.c    23 May 2002 22:51:43 -0000      1.69
+++ common/gsm-sms.c    24 May 2002 04:24:56 -0000
@@ -92,7 +92,7 @@
        sms->Validity = 4320; /* 4320 minutes == 72 hours */
        sms->DCS.Type = SMS_GeneralDataCoding;
        sms->DCS.u.General.Compressed = false;
-       sms->DCS.u.General.Alphabet = SMS_DefaultAlphabet;
+       sms->DCS.u.General.Alphabet = SMS_UCS2;
        sms->DCS.u.General.Class = 0;
 }
 
@@ -356,7 +356,7 @@
        /* Unicode */
        if ((dcs.Type & 0x08) == 0x08) {
                dprintf("Unicode message\n");
-               DecodeUnicode(output, message, length);
+               length = DecodeUnicode(output, message, length);
        } else {
                /* 8bit SMS */
                if ((dcs.Type & 0xf4) == 0xf4) {
Index: include/gsm-encoding.h
===================================================================
RCS file: /cvsroot/gnokii/gnokii/include/gsm-encoding.h,v
retrieving revision 1.9
diff -u -r1.9 gsm-encoding.h
--- include/gsm-encoding.h      4 Apr 2002 22:35:37 -0000       1.9
+++ include/gsm-encoding.h      24 May 2002 04:24:56 -0000
@@ -40,8 +40,8 @@
                        unsigned char *input, unsigned char *output);
 int Pack7BitCharacters(int offset, unsigned char *input, unsigned char 
*output);
 
-void DecodeUnicode (unsigned char* dest, const unsigned char* src, int len);
-void EncodeUnicode (unsigned char* dest, const unsigned char* src, int len);
+int DecodeUnicode (unsigned char* dest, const unsigned char* src, int len);
+int EncodeUnicode (unsigned char* dest, const unsigned char* src, int len);
 
 void DecodeAscii (unsigned char* dest, const unsigned char* src, int len);
 void EncodeAscii (unsigned char* dest, const unsigned char* src, int len);


Other things, Current CVS can not build why? Here is error messages.
make -C common/phones
make[1]: Entering directory 
`/home/hugang/deve/cvs/internet/gnokii/common/phones'
gcc -O2 -Wall  -I../../include -I/usr/X11R6/include  -c -o nk6510.o nk6510.c
nk6510.c:228: parse error before `nk6510_layout'
nk6510.c:228: warning: type defaults to `int' in declaration of `nk6510_layout'
nk6510.c:228: warning: data definition has no type or storage class
nk6510.c: In function `P6510_Initialise':
nk6510.c:365: request for member `Type' in something not a structure or union
nk6510.c:366: request for member `SendHeader' in something not a structure or 
union
nk6510.c:367: request for member `ReadHeader' in something not a structure or 
union
nk6510.c:368: request for member `Deliver' in something not a structure or union
nk6510.c:369: request for member `Submit' in something not a structure or union
nk6510.c:370: request for member `DeliveryReport' in something not a structure 
or union
nk6510.c:371: request for member `Picture' in something not a structure or union
nk6510.c:372: request for member `TextTemplate' in something not a structure or 
union
nk6510.c:373: request for member `PictureTemplate' in something not a structure 
or union
nk6510.c:374: request for member `SubmitSent' in something not a structure or 
union
nk6510.c:376: `layout' undeclared (first use in this function)
nk6510.c:376: (Each undeclared identifier is reported only once
nk6510.c:376: for each function it appears in.)
nk6510.c: In function `P6510_IncomingFolder':
nk6510.c:518: structure has no member named `SMSMessage'
nk6510.c:519: structure has no member named `SMSMessage'
nk6510.c:520: structure has no member named `SMSMessage'
nk6510.c:520: structure has no member named `SMSMessage'
nk6510.c:520: structure has no member named `SMSMessage'
nk6510.c:520: structure has no member named `SMSMessage'
nk6510.c:521: structure has no member named `SMSMessage'
nk6510.c:524: structure has no member named `SMSMessage'
nk6510.c:527: structure has no member named `SMSMessage'
nk6510.c:532: structure has no member named `SMSMessage'
nk6510.c:534: structure has no member named `SMSMessage'
nk6510.c:539: structure has no member named `SMSMessage'
nk6510.c:541: request for member `ReadHeader' in something not a structure or 
union
nk6510.c:543: request for member `ReadHeader' in something not a structure or 
union
nk6510.c:608: structure has no member named `SMSMessage'
nk6510.c:611: structure has no member named `SMSMessage'
nk6510.c: In function `P6510_GetSMSMessageStatus':
nk6510.c:698: structure has no member named `SMSMessage'
nk6510.c:703: structure has no member named `SMSMessage'
nk6510.c: In function `P6510_GetSMS':
nk6510.c:722: structure has no member named `SMSMessage'
nk6510.c:726: structure has no member named `SMSMessage'
nk6510.c:730: structure has no member named `SMSMessage'
nk6510.c:740: structure has no member named `SMSMessage'
nk6510.c:747: structure has no member named `SMSMessage'
nk6510.c: In function `P6510_IncomingSMS':
nk6510.c:814: request for member `ReadHeader' in something not a structure or 
union
nk6510.c:816: request for member `ReadHeader' in something not a structure or 
union
nk6510.c: At top level:
nk6510.c:1590: warning: `P6510_GetRingtones' defined but not used
nk6510.c:112: warning: `SMSLoop' defined but not used
make[1]: *** [nk6510.o] Error 1
make[1]: Leaving directory `/home/hugang/deve/cvs/internet/gnokii/common/phones'
make: *** [common/phones] Error 2


-- 
thanks with regards!
hugang.

***********************************
Beijing Soul Technology Co.,Ltd.
Tel:010-68425741/42/43/44
Fax:010-68425745
email:address@hidden
web:http://www.soul.com.cn

Developer, Debian GNU/Linux 
***********************************



reply via email to

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