[JDEV] Problem on UTF-8

Jeff Lai jefflai at pcg-group.com
Sun Jan 7 21:27:27 CST 2001


Hi all,

	I found that the algorithm in the functions to convert from/to UTF-8
(StrToUTF8 and UTF8ToStr) seems different from the algorithm I found in
http://czyborra.com/utf/ which states below.

putwchar(c)
{
  if (c < 0x80) {
    putchar (c);
  }
  else if (c < 0x800) {
    putchar (0xC0 | c>>6);
    putchar (0x80 | c & 0x3F);
  }
  else if (c < 0x10000) {
    putchar (0xE0 | c>>12);
    putchar (0x80 | c>>6 & 0x3F);
    putchar (0x80 | c & 0x3F);
  }
  else if (c < 0x200000) {
    putchar (0xF0 | c>>18);
    putchar (0x80 | c>>12 & 0x3F);
    putchar (0x80 | c>>6 & 0x3F);
    putchar (0x80 | c & 0x3F);
  }
}

	StrToUTF8 and UTF8ToStr just implement half of the algorithm above only.
I think that's the problem that I can't send or receive chinese message
between VB and java client.  Will it have any solution?

Jeff Lai





More information about the JDev mailing list