Difference between revisions of "LlChar"
Jump to navigation
Jump to search
Rider Linden (talk | contribs) (Created page with "{{LSL Function |func_sleep=0.0|func_energy=10.0 |func=llChar|sort=Char |func_desc=Return a single character string generated from the supplied Unicode |return_type=string |p1...") |
Frionil Fang (talk | contribs) (turns out the old "?" was incorrect and negative values also return the replacement char, not just a ?) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
|func_sleep=0.0|func_energy=10.0 | |func_sleep=0.0|func_energy=10.0 | ||
|func=llChar|sort=Char | |func=llChar|sort=Char | ||
|func_desc= | |func_desc=Construct a single character string from the supplied Unicode value. | ||
|return_type=string | |return_type=string | ||
|p1_type=integer|p1_name=val|p1_desc=Unicode value for character. | |p1_type=integer|p1_name=val|p1_desc=Unicode value for character. | ||
|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 | |func_footnote=This function returns a single character string generated from the character at the indicated UTF-32 codepoint.<br/>If {{LSLP|val}} is negative, the codepoint has no valid single-character UTF-16 representation such as a part of a surrogate pair, or is outside defined range, the Unicode replacement character "�" (0xFFFD) is returned.</br>If {{LSLP|val}} is 0, an empty string is returned. | ||
|spec | |spec | ||
|caveats | |caveats | ||
|examples= | |examples= | ||
<source lang="lsl2"> | |||
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 + "\""); | |||
} | |||
} | |||
</source> | |||
|helpers|related | |helpers|related | ||
|also_functions= | |also_functions= | ||
{{LSL DefineRow|[[llOrd]]|Convert a character into an ordinal}} | {{LSL DefineRow|[[llOrd]]|Convert a character into an ordinal}} | ||
{{LSL DefineRow|[[llHash]]|Calculate a 32bit hash for a string}} | {{LSL DefineRow|[[llHash]]|Calculate a 32bit hash for a string}} | ||
|also_articles={{LSL DefineRow||{{wikipedia|UTF- | |also_articles={{LSL DefineRow||{{wikipedia|UTF-32}}|}} | ||
|notes | |notes | ||
|cat1 | |cat1 |
Latest revision as of 12:14, 9 October 2023
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: string llChar( integer val );? | Function ID |
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.
If val is negative, the codepoint has no valid single-character UTF-16 representation such as a part of a surrogate pair, or is outside defined range, the Unicode replacement character "�" (0xFFFD) is returned.
If val is 0, an empty string is returned.
Caveats
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 + "\"");
}
}