Rev 6045 | Rev 7252 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3107 | leency | 1 | //convert text characters |
5598 | pavelyakov | 2 | #ifndef INCLUDE_LIBICONV_H |
3 | #define INCLUDE_LIBICONV_H |
||
5676 | pavelyakov | 4 | #print "[include |
3106 | leency | 5 | |
5598 | pavelyakov | 6 | #ifndef INCLUDE_KOLIBRI_H |
7 | #include "../lib/kolibri.h" |
||
8 | #endif |
||
9 | |||
3106 | leency | 10 | dword iconv_lib = #a_iconv_lib; |
11 | char a_iconv_lib[19]="/sys/lib/iconv.obj\0"; |
||
12 | |||
13 | dword iconv_open = #aIconv_open; |
||
14 | dword iconv = #aIconv; |
||
3839 | Asper | 15 | $DD 2 dup 0 |
3106 | leency | 16 | |
17 | char aIconv_open[11] = "iconv_open\0"; |
||
18 | char aIconv[6] = "iconv\0"; |
||
19 | |||
20 | |||
21 | dword ChangeCharset(dword from_chs, to_chs, conv_buf) |
||
22 | { |
||
23 | dword cd, in_len, out_len, new_buf; |
||
24 | |||
25 | iconv_open stdcall (from_chs, to_chs); //CP866, CP1251, CP1252, KOI8-RU, UTF-8, ISO8859-5 |
||
3128 | leency | 26 | if (EAX==-1) |
27 | { |
||
6045 | leency | 28 | debugln(from_chs); |
29 | debugln(to_chs); |
||
30 | debugln("iconv: wrong charset,\nuse only CP866, CP1251, CP1252, KOI8-RU, UTF-8, ISO8859-5"); |
||
3128 | leency | 31 | return 0; |
32 | } |
||
3106 | leency | 33 | cd = EAX; |
34 | |||
3128 | leency | 35 | in_len = out_len = strlen(conv_buf)+1; |
3106 | leency | 36 | new_buf = mem_Alloc(in_len); |
37 | iconv stdcall (cd, #conv_buf, #in_len, #new_buf, #out_len); |
||
38 | cd = EAX; |
||
39 | if (cd!=0) |
||
40 | { |
||
6045 | leency | 41 | debugln("iconv: something is wrong with stdcall iconv()"); |
3363 | leency | 42 | debugi(cd); |
6045 | leency | 43 | debug("in_len:"); debugi(in_len); |
44 | debug("out_len:"); debugi(out_len); |
||
3363 | leency | 45 | new_buf = free(new_buf); |
3128 | leency | 46 | return 0; |
3106 | leency | 47 | } |
3128 | leency | 48 | strcpy(conv_buf, new_buf); |
49 | free(new_buf); |
||
50 | return conv_buf; |
||
3363 | leency | 51 | } |
52 | |||
53 | |||
5690 | leency | 54 | :int cur_charset; |
5811 | leency | 55 | :char *charsets[] = { "UTF-8", "KOI8-RU", "CP1251", "CP1252", "ISO8859-5", "CP866", 0 }; |
56 | enum { CH_UTF8, CH_KOI8, CH_CP1251, CH_CP1252, CH_ISO8859_5, CH_CP866, CH_NULL }; |
||
5598 | pavelyakov | 57 | |
58 | #endif |