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