Diff for /np2/win9x/oemtext.cpp between versions 1.7 and 1.8

version 1.7, 2005/05/15 18:26:47 version 1.8, 2006/12/23 12:49:22
Line 5 Line 5
   
 // Use WinAPI version  // Use WinAPI version
   
   UINT oemtext_mbtoucs2(UINT cp, WCHAR *dst, UINT dcnt, const char *src, UINT scnt) {
 UINT oemtext_sjistoucs2(UINT16 *dst, UINT dcnt, const char *src, UINT scnt) {  
   
         int             srccnt;          int             srccnt;
         int             dstcnt;          int             dstcnt;
Line 33  UINT oemtext_sjistoucs2(UINT16 *dst, UIN Line 32  UINT oemtext_sjistoucs2(UINT16 *dst, UIN
         else {          else {
                 dstcnt = 0;                  dstcnt = 0;
         }          }
         r = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, src, srccnt, (WCHAR *)dst, dstcnt);          r = MultiByteToWideChar(cp, MB_PRECOMPOSED, src, srccnt, dst, dstcnt);
         if ((r == 0) && (dstcnt != 0)) {          if ((r == 0) && (dstcnt != 0)) {
                 r = dstcnt;                  r = dstcnt;
                 if (srccnt < 0) {                  if (srccnt < 0) {
Line 46  UINT oemtext_sjistoucs2(UINT16 *dst, UIN Line 45  UINT oemtext_sjistoucs2(UINT16 *dst, UIN
         return(r);          return(r);
 }  }
   
 UINT oemtext_ucs2tosjis(char *dst, UINT dcnt, const UINT16 *src, UINT scnt) {  UINT oemtext_ucs2tomb(UINT cp, char *dst, UINT dcnt, const WCHAR *src, UINT scnt) {
   
         int             srccnt;          int             srccnt;
         int             dstcnt;          int             dstcnt;
Line 73  UINT oemtext_ucs2tosjis(char *dst, UINT  Line 72  UINT oemtext_ucs2tosjis(char *dst, UINT 
         else {          else {
                 dstcnt = 0;                  dstcnt = 0;
         }          }
         r = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)src, srccnt, dst, dstcnt, NULL, NULL);          r = WideCharToMultiByte(cp, 0, src, srccnt, dst, dstcnt, NULL, NULL);
         if ((r == 0) && (dstcnt != 0)) {          if ((r == 0) && (dstcnt != 0)) {
                 r = dstcnt;                  r = dstcnt;
                 if (srccnt < 0) {                  if (srccnt < 0) {
Line 86  UINT oemtext_ucs2tosjis(char *dst, UINT  Line 85  UINT oemtext_ucs2tosjis(char *dst, UINT 
         return(r);          return(r);
 }  }
   
 UINT oemtext_sjistoutf8(char *dst, UINT dcnt, const char *src, UINT scnt) {  UINT oemtext_mbtoutf8(UINT cp, char *dst, UINT dcnt, const char *src, UINT scnt) {
   
         UINT    leng;          UINT    leng;
         UINT16  *ucs2;          WCHAR   *ucs2;
         UINT    ret;          UINT    ret;
   
         (void)scnt;          (void)scnt;
   
         leng = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, src, scnt, NULL, 0);          leng = MultiByteToWideChar(cp, MB_PRECOMPOSED, src, scnt, NULL, 0);
         if (leng == 0) {          if (leng == 0) {
                 return(0);                  return(0);
         }          }
         ucs2 = (UINT16 *)_MALLOC(leng * sizeof(UINT16), "");          ucs2 = (WCHAR *)_MALLOC(leng * sizeof(WCHAR), "");
         if (ucs2 == NULL) {          if (ucs2 == NULL) {
                 return(0);                  return(0);
         }          }
         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, src, scnt, (WCHAR *)ucs2, leng);          MultiByteToWideChar(cp, MB_PRECOMPOSED, src, scnt, ucs2, leng);
         if (((SINT)scnt) < 0) {          if (((SINT)scnt) < 0) {
                 leng = (UINT)-1;                  leng = (UINT)-1;
         }          }
Line 111  UINT oemtext_sjistoutf8(char *dst, UINT  Line 110  UINT oemtext_sjistoutf8(char *dst, UINT 
         return(ret);          return(ret);
 }  }
   
 UINT oemtext_utf8tosjis(char *dst, UINT dcnt, const char *src, UINT scnt) {  UINT oemtext_utf8tomb(UINT cp, char *dst, UINT dcnt, const char *src, UINT scnt) {
   
         UINT    leng;          UINT    leng;
         UINT16  *ucs2;          WCHAR   *ucs2;
         UINT    ret;          UINT    ret;
   
         (void)scnt;          (void)scnt;
Line 123  UINT oemtext_utf8tosjis(char *dst, UINT  Line 122  UINT oemtext_utf8tosjis(char *dst, UINT 
         if (leng == 0) {          if (leng == 0) {
                 return(0);                  return(0);
         }          }
         ucs2 = (UINT16 *)_MALLOC(leng * sizeof(UINT16), "");          ucs2 = (WCHAR *)_MALLOC(leng * sizeof(WCHAR), "");
         if (ucs2 == NULL) {          if (ucs2 == NULL) {
                 return(0);                  return(0);
         }          }
Line 131  UINT oemtext_utf8tosjis(char *dst, UINT  Line 130  UINT oemtext_utf8tosjis(char *dst, UINT 
         if (((SINT)scnt) < 0) {          if (((SINT)scnt) < 0) {
                 leng = (UINT)-1;                  leng = (UINT)-1;
         }          }
         ret = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)ucs2, leng, dst, dcnt, NULL, NULL);          ret = WideCharToMultiByte(cp, 0, ucs2, leng, dst, dcnt, NULL, NULL);
         _MFREE(ucs2);          _MFREE(ucs2);
         return(ret);          return(ret);
 }  }
   
   
   // ----
   
   UINT oemtext_chartoucs2(WCHAR *dst, UINT dcnt, const char *src, UINT scnt) {
   
           return(oemtext_mbtoucs2(CP_ACP, dst, dcnt, src, scnt));
   }
   
   UINT oemtext_ucs2tochar(char *dst, UINT dcnt, const WCHAR *src, UINT scnt) {
   
           return(oemtext_ucs2tomb(CP_ACP, dst, dcnt, src, scnt));
   }
   
   UINT oemtext_chartoutf8(char *dst, UINT dcnt, const char *src, UINT scnt) {
   
           return(oemtext_mbtoutf8(CP_ACP, dst, dcnt, src, scnt));
   }
   
   UINT oemtext_utf8tochar(char *dst, UINT dcnt, const char *src, UINT scnt) {
   
           return(oemtext_utf8tomb(CP_ACP, dst, dcnt, src, scnt));
   }
   
   
 // ---- textcnv  // ---- textcnv
   
 UINT textcnv_getinfo(TCINF *inf, const UINT8 *hdr, UINT hdrsize) {  UINT textcnv_getinfo(TCINF *inf, const UINT8 *hdr, UINT hdrsize) {
Line 185  UINT textcnv_getinfo(TCINF *inf, const U Line 207  UINT textcnv_getinfo(TCINF *inf, const U
   
                 case TEXTCNV_UTF8:                  case TEXTCNV_UTF8:
                         info.caps = TEXTCNV_READ | TEXTCNV_WRITE;                          info.caps = TEXTCNV_READ | TEXTCNV_WRITE;
                         info.tooem = (TCTOOEM)oemtext_utf8tosjis;                          info.tooem = (TCTOOEM)oemtext_utf8tochar;
                         info.fromoem = (TCFROMOEM)oemtext_sjistoutf8;                          info.fromoem = (TCFROMOEM)oemtext_chartoutf8;
                         break;                          break;
   
                 case TEXTCNV_UCS2:                  case TEXTCNV_UCS2:
                         info.caps = TEXTCNV_READ | TEXTCNV_WRITE;                          info.caps = TEXTCNV_READ | TEXTCNV_WRITE;
                         info.tooem = (TCTOOEM)oemtext_ucs2tosjis;                          info.tooem = (TCTOOEM)oemtext_ucs2tochar;
                         info.fromoem = (TCFROMOEM)oemtext_sjistoucs2;                          info.fromoem = (TCFROMOEM)oemtext_chartoucs2;
                         break;                          break;
         }          }
 #elif defined(OSLANG_EUC)  #elif defined(OSLANG_EUC)
Line 207  UINT textcnv_getinfo(TCINF *inf, const U Line 229  UINT textcnv_getinfo(TCINF *inf, const U
                 case TEXTCNV_DEFAULT:                  case TEXTCNV_DEFAULT:
                 case TEXTCNV_SJIS:                  case TEXTCNV_SJIS:
                         info.caps = TEXTCNV_READ | TEXTCNV_WRITE;                          info.caps = TEXTCNV_READ | TEXTCNV_WRITE;
                         info.tooem = (TCTOOEM)oemtext_sjistoutf8;                          info.tooem = (TCTOOEM)oemtext_chartoutf8;
                         info.fromoem = (TCFROMOEM)oemtext_utf8tosjis;                          info.fromoem = (TCFROMOEM)oemtext_utf8tochar;
                         break;                          break;
   
                 case TEXTCNV_UTF8:                  case TEXTCNV_UTF8:
Line 226  UINT textcnv_getinfo(TCINF *inf, const U Line 248  UINT textcnv_getinfo(TCINF *inf, const U
                 case TEXTCNV_DEFAULT:                  case TEXTCNV_DEFAULT:
                 case TEXTCNV_SJIS:                  case TEXTCNV_SJIS:
                         info.caps = TEXTCNV_READ | TEXTCNV_WRITE;                          info.caps = TEXTCNV_READ | TEXTCNV_WRITE;
                         info.tooem = (TCTOOEM)oemtext_sjistoucs2;                          info.tooem = (TCTOOEM)oemtext_chartoucs2;
                         info.fromoem = (TCFROMOEM)oemtext_ucs2tosjis;                          info.fromoem = (TCFROMOEM)oemtext_ucs2tochar;
                         break;                          break;
   
                 case TEXTCNV_UTF8:                  case TEXTCNV_UTF8:

Removed from v.1.7  
changed lines
  Added in v.1.8


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