gnokii-commit
[Top][All Lists]
Advanced

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

gnokii/common gsm-encoding.c,1.50,1.51


From: BORBELY Zoltan <address@hidden>
Subject: gnokii/common gsm-encoding.c,1.50,1.51
Date: Thu, 13 Nov 2003 00:23:26 +0000

Update of /cvsroot/gnokii/gnokii/common
In directory subversions:/tmp/cvs-serv18774/common

Modified Files:
        gsm-encoding.c 
Log Message:
utf8 encoding/decoding fixed


Index: gsm-encoding.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-encoding.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** gsm-encoding.c      3 Nov 2003 21:16:39 -0000       1.50
--- gsm-encoding.c      13 Nov 2003 00:18:07 -0000      1.51
***************
*** 555,561 ****
  {
        size_t nconv;
-       char *pin, *pout;
  
  #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_CODESET)
        iconv_t cd;
  
--- 555,561 ----
  {
        size_t nconv;
  
  #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_CODESET)
+       char *pin, *pout;
        iconv_t cd;
  
***************
*** 568,594 ****
        *pout = 0;
  #else
!       nconv = 0;
!       pin = (char *)instring;
        pout = outstring;
  
        while (inlen > 0 && outlen > 0) {
!               if (*pin < 0 || *pin > 127)
!                       *pout = '?';
!               else
                        *pout = *pin;
! 
!               inlen--;
                outlen--;
!               pin++;
                if (*pout++ == '\0') break;
        }
  #endif
!       return (nconv < 0) ?  -1 : pout - outstring;
  }
  
  int utf8_encode(char *outstring, int outlen, const char *instring, int inlen)
  {
        size_t outleft, inleft, nconv;
        char *pin, *pout;
  
        outleft = outlen;
--- 568,615 ----
        *pout = 0;
  #else
!       unsigned char *pin, *pout;
! 
!       pin = (unsigned char *)instring;
        pout = outstring;
  
        while (inlen > 0 && outlen > 0) {
!               if (*pin < 0x80) {
                        *pout = *pin;
!                       nconv = 1;
!               } else if (*pin < 0xc0) {
!                       *pout = '?';
!                       nconv = 1;
!               } else if (*pin < 0xe0) {
!                       *pout = '?';
!                       nconv = 2;
!               } else if (*pin < 0xf0) {
!                       *pout = '?';
!                       nconv = 3;
!               } else if (*pin < 0xf8) {
!                       *pout = '?';
!                       nconv = 4;
!               } else if (*pin < 0xfc) {
!                       *pout = '?';
!                       nconv = 5;
!               } else {
!                       *pout = '?';
!                       nconv = 6;
!               }
!               inlen -= nconv;
                outlen--;
!               pin += nconv;
                if (*pout++ == '\0') break;
        }
+       nconv = 0;
  #endif
!       return (nconv < 0) ?  -1 : (char *)pout - outstring;
  }
  
  int utf8_encode(char *outstring, int outlen, const char *instring, int inlen)
  {
+ #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_CODESET)
        size_t outleft, inleft, nconv;
        char *pin, *pout;
+       iconv_t cd;
  
        outleft = outlen;
***************
*** 597,603 ****
        pout = outstring;
  
- #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_CODESET)
-       iconv_t cd;
- 
        cd = iconv_open("UTF-8", nl_langinfo(CODESET));
  
--- 618,621 ----
***************
*** 606,615 ****
        iconv_close(cd);
  #else
        nconv = 0;
!       pin = (char *)instring;
        pout = outstring;
  
        while (inlen > 0 && outlen > 0) {
!               if (*pin < 0 || *pin > 127)
                        *pout = '?';
                else
--- 624,636 ----
        iconv_close(cd);
  #else
+       size_t nconv;
+       unsigned char *pin, *pout;
+ 
        nconv = 0;
!       pin = (unsigned char *)instring;
        pout = outstring;
  
        while (inlen > 0 && outlen > 0) {
!               if (*pin >= 0x80)
                        *pout = '?';
                else
***************
*** 622,626 ****
        }
  #endif
!       return (nconv < 0) ?  -1 : pout - outstring;
  }
  
--- 643,647 ----
        }
  #endif
!       return (nconv < 0) ?  -1 : (char *)pout - outstring;
  }
  





reply via email to

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