Skip to content
lsl.devlsl.devLSL Dev

llChar

function
Function syntax
string llChar(
  1. integer val// Unicode codepoint integer (ordinal) to convert.
);
Returns
string
Energy
10

Construct a single character string from the supplied Unicode value.

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. (Slua’s equivilant utf8.char instead raises the error "invalid argument #1 to 'char' (value out of range)" in this situation).If val is 0, an empty string is returned.

How to use
string result = llChar(0);
  • Value range is between 0x1–0x10FFFF
  • Values in the surrogate range 0xD800–0xDFFF will return the replacement character ”–” (0xFFFD) instead
  • Values for the special noncharacters 0xFFFE and 0xFFFF will return the replacement character instead
  • SLua’s equivilant utf8.char has none of the above caveats, and also handles 0x0 (the null character) correctly (validation script, in SLua)
  • Values for UTF-8 multibyte ranges are:
  • 1 byte: 0x0–0x7F
  • 2 bytes: 0x80–0x07FF
  • 3 bytes: 0x0800–0xFFFF
  • 4 bytes: 0x10000–0x10FFFF
Example 1
18 collapsed lines
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;
}
5 collapsed lines
llSay(0, "\"" + test_string + "\" -> [" +
llDumpList2String(test_list, ", ") + "] -> \"" + test_string2 + "\"");
}
}
  • llOrd — Convert a character into an ordinal
  • llHash — Calculate a 32bit hash for a string
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.

From the Second Life Wiki

Community documentation adapted from LlChar, by Linden Research, Inc. and contributing residents.View contributors and history.

Imported wiki revision:

  • LlChar (revision 1218701, )

Licensed under CC BY-SA 3.0. Last wiki edit: .Formatting and links have been adapted for this site; API metadata follows the LSL definitions.