[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unicode support
From: |
Pawel Kot |
Subject: |
Re: Unicode support |
Date: |
Fri, 27 Sep 2002 00:55:17 +0200 (CEST) |
On Thu, 26 Sep 2002, Hu Gang wrote:
> 00_fix_bug : fix current cvs bug
Good spotting. Thank you. Applied.
> 01_fix_unicode: support for unicode. passed in my test.
Notes and questions:
- if (mbtowc(&retval, &value, 1) == -1) return '?';
+ if (mbtowc(&retval, &value, 1) == -1) return 0;
Why that? It will truncate the string on the character that is not
supported by the current locale.
It doesn't look good:
+ if (tmp != 0)
+ dest[i - 1] = tmp; /* is right ? */
and
+ if (tmp != 0) dest[i - 1] = tmp;
It will crash on i == 0;
I would propose something like this:
static unsigned int char_decode_uni_alphabet(wchar_t value, unsigned char *dest)
{
unsigned int retval;
switch (retval = wctomb(dest, value)) {
case -1:
*dest = '?';
return 1;
default:
return retval;
}
}
[...]
void char_decode_ucs2(unsigned char* dest, const unsigned char* src, int len)
{
[...]
i += (char_decode_unicode(strtol(buf, NULL, 16), dest + i) - 1);
[...]
void char_decode_unicode(unsigned char* dest, const unsigned char* src, int len)
{
[...]
i += (char_decode_unicode(wc, dest + i) - 1);
[...]
It is completly untested, it's rather an idea how to do it.
pkot
PS. I guess encoding neither works with chineses characters. Does it?
--
mailto:address@hidden :: mailto:address@hidden
http://kt.linuxnews.pl/ :: Kernel Traffic po polsku
- Re: Unicode support, (continued)
Re: Unicode support, Pawel Kot, 2002/09/26
Re: Unicode support, Pawel Kot, 2002/09/26
Re: Unicode support,
Pawel Kot <=
Re: Unicode support, Hu Gang, 2002/09/26
Re: Unicode support, Pawel Kot, 2002/09/27
Re: Unicode support, Markus Plail, 2002/09/27
Re: Unicode support, Hu Gang, 2002/09/27
Re: Unicode support, Pawel Kot, 2002/09/27
Re: Unicode support, Pawel Kot, 2002/09/27