You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.
This shows you the differences between two versions of the page.
functions:llbase64tostring [2016-12-12 20:24 SLT] sei created |
functions:llbase64tostring [2016-12-12 20:44 SLT] (current) sei Misc fixes |
||
---|---|---|---|
Line 8: | Line 8: | ||
Converts a byte sequence containing $lart[UTF-8] characters, encoded as a $lart[Base64] string, to a $lty[string]. | Converts a byte sequence containing $lart[UTF-8] characters, encoded as a $lart[Base64] string, to a $lty[string]. | ||
- | That is, the input string is first converted to a $art[Base64]-encoded byte sequence. That byte sequence, taken as a string encoded in $art[UTF-8], is then converted to a LSL Unicode $ty[string]. | + | That is, the input string is first converted to a $art[Base64]-encoded byte sequence. That byte sequence is then interpreted as a string encoded in $art[UTF-8], and converted to a LSL Unicode $ty[string]. |
===== Parameters ===== | ===== Parameters ===== | ||
=== base64str === | === base64str === | ||
- | A $lty[string] expressed in $lart[Base64] that represents the byte string to convert. | + | A $lty[string] expressed in $lart[Base64] that represents the $art[UTF-8] byte sequence to convert. |
===== Return value ===== | ===== Return value ===== | ||
Line 21: | Line 21: | ||
===== Notes ===== | ===== Notes ===== | ||
- | * Invalid $art[UTF-8] characters and NUL characters (U+0000) that are not at the end of the string, are converted to question marks ("?"). If the string ends in a NUL character, it's just stripped. | + | * In the corresponding byte sequence, ''NUL'' characters (U+0000) that are not at the end of the string, and invalid $art[UTF-8] characters, are converted to question marks ("?"). If the string ends in a ''NUL'' character, it's just stripped. |
+ | * In $LSO, in a few cases it's possible to obtain invalid $art[UTF-8] with this function. | ||
* Padding is ignored; parsing proceeds until the first non-$art[Base64] character is found. | * Padding is ignored; parsing proceeds until the first non-$art[Base64] character is found. | ||
Line 40: | Line 41: | ||
s = llBase64ToString("SGVsbG8"); // same (padding is ignored) | s = llBase64ToString("SGVsbG8"); // same (padding is ignored) | ||
+ | |||
+ | s = llBase64ToString("AAAA"); // sets s to "??" | ||
+ | // (trailing NUL is stripped; first two NULs are converted to "?") | ||
</code> | </code> | ||
Line 45: | Line 49: | ||
* $lfn[llStringToBase64] encodes a string as $lart[UTF-8], then the $art[UTF-8] as $lart[Base64]. It's the inverse operation of $fn[llBase64ToString]. | * $lfn[llStringToBase64] encodes a string as $lart[UTF-8], then the $art[UTF-8] as $lart[Base64]. It's the inverse operation of $fn[llBase64ToString]. | ||
- | * $lfn[llIntegerToBase64] and $lfn[llBase64ToInteger] encode or decode an integer in $art[Base64] representation. | + | * Use $lfn[llIntegerToBase64] and $lfn[llBase64ToInteger] to encode/decode an integer in $art[Base64] representation. |
* $lfn[llXorBase64] calculates the bitwise XOR of corresponding bytes represented by two $art[Base64] strings, byte by byte. | * $lfn[llXorBase64] calculates the bitwise XOR of corresponding bytes represented by two $art[Base64] strings, byte by byte. | ||
+ | * $lfn[llEscapeURL] and $lfn[llUnescapeURL] also encode/decode a string in $art[UTF-8], but to a different representation (not Base64). |