Subversion Repositories Kolibri OS

Rev

Rev 3128 | Rev 3839 | 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
3106 leency 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
3128 leency 21
	if (EAX==-1)
22
	{
3363 leency 23
		debug(from_chs);
24
		debug(to_chs);
3128 leency 25
		debug("iconv: wrong charset,\nuse only CP866, CP1251, CP1252, KOI8-RU, UTF-8, ISO8859-5");
26
		return 0;
27
	}
3106 leency 28
	cd = EAX;
29
 
3128 leency 30
	in_len = out_len = strlen(conv_buf)+1;
3106 leency 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
	{
3107 leency 36
		debug("iconv: something is wrong with stdcall iconv()");
3363 leency 37
		debugi(cd);
3106 leency 38
		debug("in_len");
3363 leency 39
		debugi(in_len);
3106 leency 40
		debug("out_len");
3363 leency 41
		debugi(out_len);
42
		new_buf = free(new_buf);
3128 leency 43
		return 0;
3106 leency 44
	}
3128 leency 45
	strcpy(conv_buf, new_buf);
46
	free(new_buf);
47
	return conv_buf;
3363 leency 48
}
49
 
50
 
51
char *charsets[] = { " ", "UTF-8", "KOI8-RU", "CP1251",  "CP1252", "ISO8859-5", "CP866"};
52
int cur_charset;
53
enum {
54
	CH_NULL,
55
	CH_UTF8,
56
	CH_KOI8,
57
	CH_CP1251,
58
	CH_CP1252,
59
	CH_ISO8859_5,
60
	CH_CP866
61
};