Subversion Repositories Kolibri OS

Rev

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