--- In [email protected], "entropyreduction"
<alancampbelllists+ya...@...> wrote:
>
> unicodePlugin0.73_090902.zip
> in
> http://tech.groups.yahoo.com/group/power-pro/files/0_TEMP_/AlansPluginProvisional/
>
> ; musical G clef == 0xD834 0xDD1E
> local uStr = unicode.from_nums(0x1D11E)
> unicode.set_base(0)
> ;gives expected results
> win.debug(win.hex(uStr[0]), win.hex(uStr[1]))
>
> win.debug(case("tonumx", uStr.to_utf8))
> ; didn't give same result
> ; your function, may have used out of sate version
> win.debug(ReturnUTF8(0x1D11E))
>
> ;but same goes for < 0xFFFF
> win.debug(case("tonumx", unicode.from_nums(0x1D11).to_utf8))
> ReturnUTF8(0x1D11)
>
ReturnUTF8 expects input of a code point string, e.g., ReturnUTF8("1D11") not
the decimal number 0x1D11
> ; your function, may have used out of sate version
Think I previously posted only one version, but I have since revised it a bit.
Here is the latest:
Function ReturnUTF8(c)
;c is a code point, e.g., 10400, FF, etc.
c=convertbase(c,16,10)
local u=repeat("\x20",4)
if (c < 0x80) do
u = c.fromnum
elseif (c < 0x800)
u[0] = (0xC0 | c>>6).fromnum
u[1] = (0x80 | c & 0x3F).fromnum
elseif (c < 0x10000)
u[0]= (0xE0 | c>>12).fromnum
u[1]= (0x80 | c>>6 & 0x3F).fromnum
u[2]= (0x80 | c & 0x3F).fromnum
elseif (c < 0x200000)
u[0] = (0xF0 | c>>18).fromnum
u[1] = (0x80 | c>>12 & 0x3F).fromnum
u[2]= (0x80 | c>>6 & 0x3F).fromnum
u[3]= (0x80 | c & 0x3F).fromnum
endif
u=u.trim("\x20",2)
quit(u)
Regards,
Sheri