Rev 8281 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8281 | Rev 9304 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | 4 | ||
5 | #ifndef INCLUDE_KOLIBRI_H |
5 | #ifndef INCLUDE_KOLIBRI_H |
6 | #include "../lib/kolibri.h" |
6 | #include "../lib/kolibri.h" |
Line -... | Line 7... | ||
- | 7 | #endif |
|
- | 8 | ||
- | 9 | #ifndef INCLUDE_ENCODING_H |
|
- | 10 | #include "../lib/encoding.h" |
|
7 | #endif |
11 | #endif |
8 | 12 | ||
Line 9... | Line 13... | ||
9 | dword iconv_lib = #a_iconv_lib; |
13 | dword iconv_lib = #a_iconv_lib; |
10 | char a_iconv_lib[]="/sys/lib/iconv.obj"; |
14 | char a_iconv_lib[]="/sys/lib/iconv.obj"; |
Line 21... | Line 25... | ||
21 | 25 | ||
22 | dword ChangeCharset(dword from_chs, to_chs, conv_buf) |
26 | dword ChangeCharset(dword from_chs, to_chs, conv_buf) |
23 | { |
27 | { |
Line 24... | Line -... | ||
24 | dword cd, in_len, out_len, new_buf; |
- | |
25 | - | ||
26 | from_chs = from_chs*10+#charsets; |
- | |
27 | - | ||
28 | //debug("iconv: from_chs = "); debugln(from_chs); |
- | |
29 | //debug("iconv: to_chs = "); debugln(to_chs); |
28 | dword cd, in_len, out_len, new_buf; |
30 | 29 | ||
31 | iconv_open stdcall (from_chs, to_chs); //CP866, CP1251, CP1252, KOI8-RU, UTF-8, ISO8859-5 |
30 | iconv_open stdcall (from_chs*10+#charsets, to_chs*10+#charsets); |
32 | if (EAX==-1) { |
31 | if (EAX==-1) { |
33 | debugln("iconv: unsupported charset"); |
32 | debugln("iconv: unsupported charset"); |
34 | return 0; |
33 | return 0; |
Line 35... | Line 34... | ||
35 | } |
34 | } |
- | 35 | cd = EAX; |
|
36 | cd = EAX; |
36 | |
37 | 37 | in_len = strlen(conv_buf)+1; |
|
38 | in_len = out_len = strlen(conv_buf)+1; |
38 | out_len = in_len * 2; |
39 | new_buf = mem_Alloc(in_len); |
39 | new_buf = mem_Alloc(out_len); |
40 | iconv stdcall (cd, #conv_buf, #in_len, #new_buf, #out_len); |
40 | iconv stdcall (cd, #conv_buf, #in_len, #new_buf, #out_len); |
41 | if (EAX!=0) |
- | |
42 | { |
41 | if (EAX!=0) |
43 | cd = EAX; |
42 | { |
44 | debugval("iconv: something is wrong with stdcall iconv()", cd); |
- | |
45 | debugval("in_len", in_len); |
43 | cd = EAX; |
46 | debugval("out_len", out_len); |
44 | debugval("iconv failed", cd); |
- | 45 | if (from_chs == CH_UTF8) && (to_chs == CH_CP866) { |
|
47 | new_buf = free(new_buf); |
46 | utf8rutodos(conv_buf); |
- | 47 | } |
|
48 | return conv_buf; |
48 | } else { |
49 | } |
49 | strcpy(conv_buf, new_buf); |
50 | strcpy(conv_buf, new_buf); |
50 | } |
Line 51... | Line 51... | ||
51 | free(new_buf); |
51 | free(new_buf); |
52 | return conv_buf; |
52 | return conv_buf; |