Diff for /xmil/common/ucscnv.c between versions 1.1 and 1.3

version 1.1, 2004/08/19 09:56:43 version 1.3, 2008/06/02 20:07:30
Line 2 Line 2
 #include        "ucscnv.h"  #include        "ucscnv.h"
   
   
 // ---- UCS2  /* UCS2 */
   
 UINT ucscnv_utf8toucs2(UINT16 *dst, UINT dcnt, const char *src, UINT scnt) {  UINT ucscnv_utf8toucs2(UINT16 *dst, UINT dcnt, const char *src, UINT scnt) {
   
         UINT    orgdcnt;          UINT    orgdcnt;
         UINT    c;          UINT    c;
   
         (void)scnt;  
   
         orgdcnt = dcnt;  
         if (dcnt == 0) {          if (dcnt == 0) {
                 dst = NULL;                  dst = NULL;
         }          }
         dcnt--;          else {
                   dcnt--;
           }
           orgdcnt = dcnt;
         while(dcnt) {          while(dcnt) {
                 if (src[0] == '\0') {                  if ((scnt == 0) || (src[0] == '\0')) {
                         break;                          break;
                 }                  }
                 else if (!(src[0] & 0x80)) {                  else if (!(src[0] & 0x80)) {
                         c = src[0];                          c = src[0];
                         src += 1;                          src += 1;
                           scnt -= 1;
                 }                  }
                 else if ((src[0] & 0xe0) == 0xc0) {                  else if ((src[0] & 0xe0) == 0xc0) {
                         if ((src[1] & 0xc0) != 0x80) {                          if ((scnt < 2) || ((src[1] & 0xc0) != 0x80)) {
                                 break;                                  break;
                         }                          }
                         c = ((src[0] & 0x1f) << 6) + (src[1] & 0x3f);                          c = ((src[0] & 0x1f) << 6) + (src[1] & 0x3f);
                         src += 2;                          src += 2;
                           scnt -= 2;
                 }                  }
                 else if ((src[0] & 0xf0) == 0xe0) {                  else if ((src[0] & 0xf0) == 0xe0) {
                         if (((src[1] & 0xc0) != 0x80) ||                          if ((scnt < 3) ||
                                 ((src[2] & 0xc0) != 0x80)) {                                  ((src[1] & 0xc0) != 0x80) || ((src[2] & 0xc0) != 0x80)) {
                                 break;                                  break;
                         }                          }
                         c = ((src[0] & 0x0f) << 12) +                          c = ((src[0] & 0x0f) << 12) +
                                                                 ((src[1] & 0x3f) << 6) + (src[2] & 0x3f);                                                                  ((src[1] & 0x3f) << 6) + (src[2] & 0x3f);
                         src += 3;                          src += 3;
                           scnt -= 3;
                 }                  }
                 else {                  else {
                         break;                          break;
Line 60  UINT ucscnv_ucs2toutf8(char *dst, UINT d Line 63  UINT ucscnv_ucs2toutf8(char *dst, UINT d
         UINT    orgdcnt;          UINT    orgdcnt;
         UINT    c;          UINT    c;
   
         (void)scnt;  
   
         orgdcnt = dcnt;  
         if (dcnt == 0) {          if (dcnt == 0) {
                 dst = NULL;                  dst = NULL;
         }          }
         dcnt--;          else {
                   dcnt--;
           }
           orgdcnt = dcnt;
         while(dcnt) {          while(dcnt) {
                   if (scnt == 0) {
                           break;
                   }
                   scnt--;
                 c = *src++;                  c = *src++;
                 if (!c) {                  if (!c) {
                         break;                          break;

Removed from v.1.1  
changed lines
  Added in v.1.3


RetroPC.NET-CVS <cvs@retropc.net>