Difference between revisions of "LlChar"

From Second Life Wiki
Jump to navigation Jump to search
(Note fallback return value if input is negative)
(return value for chars that aren't valid UTF-16)
Line 7: Line 7:
|p1_hover=Unicode value for character.
|p1_hover=Unicode value for character.
|return_text=
|return_text=
|func_footnote=This function returns a single character string generated from the character at the indicated UTF-32 codepoint.  Returns "?" (Unicode 0x0F) if val is negative.
|func_footnote=This function returns a single character string generated from the character at the indicated UTF-32 codepoint.  Returns "?" (Unicode 0x0F) if val is negative.<br/>Returns the Unicode replacement character "�" (0xFFFD) for characters that do not have a proper single-character representation in UTF-16 (multi-character surrogates or otherwise invalid).
|spec
|spec
|caveats
|caveats

Revision as of 11:08, 9 October 2023

Summary

Function: string llChar( integer val );
0.0 Forced Delay
10.0 Energy

Construct a single character string from the supplied Unicode value.
Returns a string

• integer val Unicode value for character.

This function returns a single character string generated from the character at the indicated UTF-32 codepoint. Returns "?" (Unicode 0x0F) if val is negative.
Returns the Unicode replacement character "�" (0xFFFD) for characters that do not have a proper single-character representation in UTF-16 (multi-character surrogates or otherwise invalid).

Examples

default
{
    touch_start(integer total_number)
    {
        string test_string = "The quick brown fox jumped over the lazy dog";
        list test_list = [];
        string test_string2 = "";
        
        integer index;
        integer ord;
        for (index = 0; index < llStringLength(test_string); ++index)
        {
            ord = llOrd(test_string, index);
            test_list = test_list + [ ord ];
        }
        
        string char;
        for (index = 0; index < llGetListLength(test_list); ++index)
        {
            ord = llList2Integer(test_list, index);
            char = llChar(ord);
            test_string2 = test_string2 + char;
        }
        
        llSay(0, "\"" + test_string + "\" -> [" + 
            llDumpList2String(test_list, ", ") + "] -> \"" + test_string2 + "\"");
    }
}

See Also

Functions

• llOrd Convert a character into an ordinal
• llHash Calculate a 32bit hash for a string

Articles

•  "Wikipedia logo"UTF-32

Deep Notes

Signature

function string llChar( integer val );