Hi,

Am Freitag, 12. Aug 2005, 03:11:11 +0900 schrieb balony / gmail.com:
> 
> Is this for real? Is there no workaround for me to get my data to the
> server with uft8 encoding?

I convert utf16 to utf8 using the workaround below. Having a
short look at Wikipedia, e.g., should lead to a similar
solution easily.

Bertram


------------------------------


def utf16to8 utf16
  endian = if utf16.slice! /\A\xff\xfe/ then
    "v"
  elsif       utf16.slice! /\A\xfe\xff/ then
    "n"
  else
    "S"
  end
  utf8 = ""
  utf16.scan /../ do |bb|
    b, = bb.unpack endian
    if b < 0x80 then
      utf8 << b
    elsif b < 0x800 then
      utf8 << (0b11000000 | (b >>  6 &  0b11111))
      utf8 << (0b10000000 | (b       & 0b111111))
    elsif b < 0x10000 then
      utf8 << (0b11100000 | (b >> 12 &   0b1111))
      utf8 << (0b10000000 | (b >>  6 & 0b111111))
      utf8 << (0b10000000 | (b       & 0b111111))
    else
      utf8 << (0b11110000 | (b >> 18 &    0b111))
      utf8 << (0b10000000 | (b >> 12 & 0b111111))
      utf8 << (0b10000000 | (b >>  6 & 0b111111))
      utf8 << (0b10000000 | (b       & 0b111111))
    end
  end
  utf8
end


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de