Difference between revisions of "User:Cory Fimicoloud"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 1: Line 1:
{{User:Cory Fimicoloud/hcard}}
{{User:Cory Fimicoloud/hcard}}
==LSL Functions==
Functions I have created. Will add more as I go through my scripts.
''Will create a separate page for them and categorize/move the functions into it later.''
===UTF8Len===
Returns the UTF-8 byte count of the string passed to it.
<lsl>
integer UTF8Len(string fsString)
{
// Author: Cory Fimicoloud
// License: http://creativecommons.org/licenses/by-sa/3.0/us/
integer liLen = ~llStringLength(fsString);
string lsChar = "";
string lsEnc = "";
integer liByteLen = 0;
while (++liLen < 0)
{
lsEnc = llEscapeURL((lsChar = llGetSubString(fsString, liLen, liLen)));
if (lsChar != lsEnc)
liByteLen += llStringLength(lsEnc) / 3;
else
++liByteLen;
}
return liByteLen;
}
default
{
state_entry()
{
string lsString = "Can I have $10 and 7¢, please? I would prefer it in €'s though."; // Length is 63 characters. Each of the characters uses 1 byte except for ¢ (2 bytes) and € (3 bytes). 66 bytes.
llOwnerSay("'" + lsString + "' is " + (string)UTF8Len(lsString) + " bytes.");
}
}</lsl>
===UTF8Split===
Returns a list containing the string passed to it, split every fiSplit bytes.
<lsl>
list UTF8Split(string fsString, integer fiSplit)
{
// Author: Cory Fimicoloud
// License: http://creativecommons.org/licenses/by-sa/3.0/us/
string lsSplit = "";
list laSplit = [];
integer liLen = ~llStringLength(fsString);
string lsChar = "";
string lsEnc = "";
integer liByteLen = 0;
while (++liLen < 0)
{
lsChar = llGetSubString(fsString, liLen, liLen);
lsEnc = llEscapeURL(lsChar);
if (lsChar != lsEnc)
liByteLen += llStringLength(lsEnc) / 3;
else
++liByteLen;
if (liByteLen <= fiSplit)
lsSplit += lsChar;
else
{
laSplit += [lsSplit];
lsSplit = lsChar;
liByteLen = 0;
}
}
return laSplit + [lsSplit];
}
default
{
state_entry()
{
list laSplit = UTF8Split("Can I have $10 and 7¢, please? I would prefer it in €'s though.", 33);
llOwnerSay("UTF8Split\n==========\t0: " + llList2String(laSplit, 0) + "\n\t1: " + llList2String(laSplit, 0));
}
}</lsl>
==See Also==
* {{Jira Reporter}}
{{ISO 639-3/cat-speaking|eng}}
{{ISO 639-3/cat-speaking|eng}}
{{skills
{{skills
|Scripter=*
|Scripter=*
}}
}}

Revision as of 23:22, 30 October 2008

Profile
Born:
Sat 12th May 2007

LSL Functions

Functions I have created. Will add more as I go through my scripts. Will create a separate page for them and categorize/move the functions into it later.

UTF8Len

Returns the UTF-8 byte count of the string passed to it. <lsl> integer UTF8Len(string fsString) { // Author: Cory Fimicoloud // License: http://creativecommons.org/licenses/by-sa/3.0/us/ integer liLen = ~llStringLength(fsString); string lsChar = ""; string lsEnc = ""; integer liByteLen = 0; while (++liLen < 0) { lsEnc = llEscapeURL((lsChar = llGetSubString(fsString, liLen, liLen))); if (lsChar != lsEnc) liByteLen += llStringLength(lsEnc) / 3; else ++liByteLen; } return liByteLen; } default { state_entry() { string lsString = "Can I have $10 and 7¢, please? I would prefer it in €'s though."; // Length is 63 characters. Each of the characters uses 1 byte except for ¢ (2 bytes) and € (3 bytes). 66 bytes. llOwnerSay("'" + lsString + "' is " + (string)UTF8Len(lsString) + " bytes."); } }</lsl>

UTF8Split

Returns a list containing the string passed to it, split every fiSplit bytes. <lsl> list UTF8Split(string fsString, integer fiSplit) { // Author: Cory Fimicoloud // License: http://creativecommons.org/licenses/by-sa/3.0/us/ string lsSplit = ""; list laSplit = []; integer liLen = ~llStringLength(fsString); string lsChar = ""; string lsEnc = ""; integer liByteLen = 0; while (++liLen < 0) { lsChar = llGetSubString(fsString, liLen, liLen); lsEnc = llEscapeURL(lsChar); if (lsChar != lsEnc) liByteLen += llStringLength(lsEnc) / 3; else ++liByteLen; if (liByteLen <= fiSplit) lsSplit += lsChar; else { laSplit += [lsSplit]; lsSplit = lsChar; liByteLen = 0; } } return laSplit + [lsSplit]; } default { state_entry() { list laSplit = UTF8Split("Can I have $10 and 7¢, please? I would prefer it in €'s though.", 33); llOwnerSay("UTF8Split\n==========\t0: " + llList2String(laSplit, 0) + "\n\t1: " + llList2String(laSplit, 0)); } }</lsl>

See Also