Jump to content

Quickie: UTF-8 encoded text example for llDialog test


KT Kingsley
 Share

You are about to reply to a thread that has been inactive for 1112 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Could someone please post an example of a string that contains UTF-8 encoded characters that would return TRUE here:

llStringLength (utf8_string) < 25

but would cause an script error when included as the button text in an llDialog call:

llDialog (llGetOwner (), "UTF-8 test", ["This", "That", utf8_string], PUBLIC_CHANNEL);
(I've no doubt that the llBase64ToString(llGetSubString(llStringToBase64(theString), 0, 31)) snippet in the wiki page for llDialog works as it should, but I would like to see for myself. UTF-8 encoding isn't something I'm familiar with.)
Link to comment
Share on other sites

default
{
    state_entry()
    {
        string test = "123456789 123456789 123†"; // 24 characters
        llOwnerSay("Length: " + (string)llStringLength(test)); // "Length: 24"

        llDialog(llGetOwner(), "test", [test], 0); // Doesn't work.
    }
}

† is a non-ASCII character. (Two bytes in UTF-8, decimal value 134, where 127 is the last one-byte character.)

llStringLength recognizes that it's just one character, but llDialog doesn't want more than 24 bytes.

Basically, look up any ASCII table; any character that's not on that list is more than one byte and you can't trust it.

As another example, ꖅ (decimal 42373) is a character that uses 3 bytes.

llDialog(llGetOwner(), "test", ["ꖅꖅꖅꖅꖅꖅꖅꖅ"], 0); // Works, string length 8, 24 bytes.
llDialog(llGetOwner(), "test", ["ꖅꖅꖅꖅꖅꖅꖅꖅA"], 0); // Doesn't work, 25 bytes.

 

Edited by Wulfie Reanimator
  • Thanks 2
Link to comment
Share on other sites

  • 1 year later...
You are about to reply to a thread that has been inactive for 1112 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...