找到搞出在SL內say中文字的方法

http://wiki.secondlife.com/wiki/Library_Combined_Library

 

阿迪是說,這是先把Unicode轉成UTF8

像以下程式會說"你":
string UnicodeIntegerToUTF8(integer input)//Mono Safe, LSO Safe
{
    integer bytes = llCeil(llLog(input) / 0.69314718055994530941723212145818);
    bytes = (input >= 0x80) * (bytes + ~(((1 << bytes) - input) > 0)) / 5;//adjust
    string result = "%" + byte2hex((input >> (6 * bytes)) | ((0x3F80 >> bytes) << !

bytes));
    while (bytes)
        result += "%" + byte2hex((((input >> (6 * (bytes = ~-bytes))) | 0x80) &

0xBF));
    return llUnescapeURL(result);
}
 
string byte2hex(integer x)//Mono Safe, LSO Safe
{//Helper function for use with unicode characters.
    integer y = (x >> 4) & 0xF;
    return llGetSubString(hexc, y, y) + llGetSubString(hexc, x & 0xF, x & 0xF);
}//This function would benifit greatly from the DUP opcode, it would remove 19 bytes.
 
string hexc="0123456789ABCDEF";

default
{
    state_entry()
    {
        llSay(0,UnicodeIntegerToUTF8(20320));
    }
}