Jump to content

llDialog error when button uses non-standard font


Simnelia Petrichor
 Share

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

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

Recommended Posts

So I want to use llDialog to display a list of the display names of nearby avatars gathered by llSensor.  I know that a button can't have a label longer than 24 characters so I use llGetSubString to make sure none of the names exceed that.

My problem is, one of the nearby avatars has the name "Riley 横バ火".

LSL has no problem with that - it considers it to be 9 characters long.  But put it on a button in llDialog and you get an error - "button labels must be 24 or fewer characters long".

Experimenting, I find I can make a button that displays the first 8 characters of the name.  I can also display the last 8 characters of the name.  It's as though the button treats each character of the name as being 3 characters long.

Anyone seen this issue before?  Any advice?

Link to comment
Share on other sites

22 minutes ago, Love Zhaoying said:

I believe you are using the “display name”, which can include Unicode characters (making the byte length longer than 24 even if it appears shorter). Try using llGetUserName or llKey2Name instead. I’m sure someone will correct me, if I’m wrong.

I use key2name. Could i suppose use numbered buttons rather than the name and list the names above. Thinking about i would use numbered buttons because people change their user names. They can not change their key.

Edited by steph Arnott
Link to comment
Share on other sites

Yeah, it's UTF8 encoding using up more bytes per character, where the length of dialog label (and other stuff) is byte-limited. As annoying as some unicode Display names may be, it's also essential for internationalization, so it would be nice if it worked. There have been jiras asking for a change since 2007. Sloping around the links and comments I eventually got to Strife's workaround for counting the byte-length of a character string which might be used in a loop that lops off a character at a time from the end until the remainder fits the limit.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

The specific advice in the LSL wiki is

An error will be shouted on DEBUG_CHANNEL, if...

  • there are more than 12 buttons.
  • any list item is not a string.
  • any list item string length (measured in bytes, using UTF-8 encoding) is zero or greater than 24.
    • In other words, a button's text when encoded as UTF-8 cannot be longer than 24 bytes or a empty string.
    • This snippet can be used to truncate the string without giving an error: llBase64ToString(llGetSubString(llStringToBase64(theString), 0, 31))

Give it a shot..

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

My advice for a workaround would be to display a numbered list of names, and have the buttons display the numbers.   Click the corresponding number to chose a particular name.

That's how I always handle names in dialogs now.    I don't like to use llGetUsername for these purposes because people clearly prefer to be called by the name they've chosen as their display name and often it's the only name people see in their viewers, at least without taking extra steps to see what the avatar's username is.

Fortunately, there's a very good example readily to hand, by Rolig.   I would suggest trying that approach and see how it suits you

 

  • Like 3
Link to comment
Share on other sites

If I were to run into this 

9 hours ago, Simnelia Petrichor said:

My problem is, one of the nearby avatars has the name "Riley 横バ火".

LSL has no problem with that - it considers it to be 9 characters long.  But put it on a button in llDialog and you get an error - "button labels must be 24 or fewer characters long".

 

Ignoring the (excellent) solutions already given, if I were to run into this problem I would prolly do something like:
 

default
{
    state_entry()
    {
        list names = ["bob", "User With A Super Duper Long Display Name", "Riley 横バ火", "hrHUffhrUrrSgF39457"];
        integer n;
        for(n=0;n<llGetListLength(names);++n)
        {
            string newname = llGetSubString(llList2String(names, n), 0, 7);
            names = llListReplaceList( names, [newname], n, n );
        }
        llDialog(llGetOwner(), "Random text", names, DEBUG_CHANNEL);
    }
}

This will truncate ALL names to 8 characters, and as long as the script were for my own use, it would probably have been good enough for me 🙂

Now, in addition, I have been looking on the wiki if there's a way to detect multibyte characters, but I was unsuccessful. It would have made for a much more elegant solution if there was such a method.

TL;DR The solutions given by the others are probably (definitely) much better than mine, but I wanted to put in my two lindens worth anyway 😉 

Link to comment
Share on other sites

19 hours ago, Rolig Loon said:

The specific advice in the LSL wiki is

An error will be shouted on DEBUG_CHANNEL, if...

  • there are more than 12 buttons.
  • any list item is not a string.
  • any list item string length (measured in bytes, using UTF-8 encoding) is zero or greater than 24.
    • In other words, a button's text when encoded as UTF-8 cannot be longer than 24 bytes or a empty string.
    • This snippet can be used to truncate the string without giving an error: llBase64ToString(llGetSubString(llStringToBase64(theString), 0, 31))

Give it a shot..

Thanks for all the responses - this is the way I'll go.  Slightly embarrassed with myself that I didn't see it in the wiki now!

Link to comment
Share on other sites

I have written a script that selects the display name for processing if it is safe. And the user name when the display name contains characters that cannot be processed by certain scripts. AFAIK it's the best possible solution if you want to use display names:

https://community.secondlife.com/forums/topic/353136-object-copying-avatar-display-name-or-username/

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1924 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...