? Makefile.global ? config.cache ? config.log ? config.status ? configure ? common/gsm-sms.c.u ? common/vcal.c ? gnokii/gnokii ? gnokiid/gnokiid ? include/config.h ? include/config.h.in ? packaging/RedHat/gnokii.spec ? packaging/Slackware/SlackBuild ? po/Makefile ? po/Makefile.in ? po/cs.gmo ? po/de.gmo ? po/et.gmo ? po/fi.gmo ? po/gnokii.pot ? po/it.gmo ? po/nl.gmo ? po/pl.gmo ? po/sk.gmo ? po/sl.gmo ? utils/mgnokiidev ? xgnokii/xgnokii 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 17 May 2002 09:48:31 -0000 @@ -31,6 +31,7 @@ #include #include #include +#include #include "misc.h" #include "gsm-common.h" @@ -252,30 +253,54 @@ 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; ) { + mbstate_t state; + memset(&state , '\0', sizeof(mbstate_t)); + + 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; ) { + mbstate_t state; + wchar_t wc; + memset(&state , '\0', sizeof(mbstate_t)); + + 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.59 diff -u -r1.59 gsm-sms.c --- common/gsm-sms.c 17 May 2002 00:22:09 -0000 1.59 +++ common/gsm-sms.c 17 May 2002 09:48:34 -0000 @@ -91,7 +91,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; } @@ -355,7 +355,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 17 May 2002 09:48:35 -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);