Subversion Repositories Kolibri OS

Rev

Rev 3107 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //convert text characters
  2.  
  3. dword iconv_lib = #a_iconv_lib;
  4. char a_iconv_lib[19]="/sys/lib/iconv.obj\0";
  5.  
  6. dword iconv_open     = #aIconv_open;
  7. dword iconv          = #aIconv;
  8.  
  9. dword  am5__ = 0x0;
  10. dword  bm5__ = 0x0;
  11.  
  12. char aIconv_open[11] = "iconv_open\0";
  13. char aIconv[6]       = "iconv\0";
  14.  
  15.  
  16. dword ChangeCharset(dword from_chs, to_chs, conv_buf)
  17. {
  18.         dword cd, in_len, out_len, new_buf;    
  19.  
  20.         iconv_open stdcall (from_chs, to_chs); //CP866, CP1251, CP1252, KOI8-RU, UTF-8, ISO8859-5
  21.         if (EAX==-1)
  22.         {
  23.                 debug (from_chs);
  24.                 debug (to_chs);
  25.                 debug("iconv: wrong charset,\nuse only CP866, CP1251, CP1252, KOI8-RU, UTF-8, ISO8859-5");
  26.                 return 0;
  27.         }
  28.         cd = EAX;
  29.  
  30.         in_len = out_len = strlen(conv_buf)+1;
  31.         new_buf = mem_Alloc(in_len);
  32.         iconv stdcall (cd, #conv_buf, #in_len, #new_buf, #out_len);
  33.         cd = EAX;
  34.         if (cd!=0)
  35.         {
  36.                 debug("iconv: something is wrong with stdcall iconv()");
  37.                 debug(itoa(cd));
  38.                 debug("in_len");
  39.                 debug(itoa(in_len));
  40.                 debug("out_len");
  41.                 debug(itoa(out_len));
  42.                 new_buf = 0;
  43.                 return 0;
  44.         }
  45.         strcpy(conv_buf, new_buf);
  46.         free(new_buf);
  47.         return conv_buf;
  48. }