[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unicode changes in CVS. Please test.
From: |
Pawel Kot |
Subject: |
Re: Unicode changes in CVS. Please test. |
Date: |
Fri, 27 Sep 2002 23:35:48 +0200 (CEST) |
On Fri, 27 Sep 2002, Markus Plail wrote:
> Please test the new unicode code in CVS. I succesfully wrote chinese
> characters to my phonebook (which it obviously couldn't display) and
> read them back. Hu Gang's test also worked fine.
> So please test SMS sending and all other stuff you can think of.
More thoughts on the fix. For now just on decoding (encoding seems also a
bit wrong).
unsigned int char_decode_unicode(...)
{
int i, length = 0, pos = 0;
for (i = 0; i < len / 2; i++) {
length = wctomb(dest, (src[i * 2] << 8) | src[(i * 2) + 1]);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The problem here is that we assume that the wide character is 2 bytes
wide. I'm afraid it is more complicated. We should do something like:
d = dest;
for (i = 0; i < len; i++) {
wchar = 0;
old = i;
for (j = 0, j < MB_CUR_MAX && length == -1 && i < len; j++) {
wchar = (wchar << 8) | src[i++];
length = wctomb(dest, wchar);
}
if (length == -1) {
i = old;
*dest = '?';
length = 1;
}
dest += length;
}
return dest - d;
Description:
we may have different width of the characters. If wctobm() fails, we
should try to add one more character. If it fails with the maximal length,
we rewind to its length 1 and insert '?'.
Again, this is completly untested, do think about this and then test it
:-)
pkot
--
mailto:address@hidden :: mailto:address@hidden
http://kt.linuxnews.pl/ :: Kernel Traffic po polsku