Difference between revisions of "Lua:byteTableToWideString"
Jump to navigation
Jump to search
m |
m (Syntax Highlighting.) |
||
| Line 24: | Line 24: | ||
===Examples=== | ===Examples=== | ||
| − | < | + | <syntaxhighlight lang="lua" line> |
local str = byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00}) | local str = byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00}) | ||
print(str) -- Output: ABC | print(str) -- Output: ABC | ||
| − | </ | + | </syntaxhighlight> |
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
Latest revision as of 15:49, 25 June 2026
Converts a table of bytes to a wide string (UTF-16/Unicode), and then to a Lua string.
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| Table | Table | A table containing the bytes to convert to a wide string (UTF-16/Unicode). |
Returns[edit]
String — The resulting string formed from the wide string byte values.
Explanation[edit]
Each pair of bytes in the table is interpreted as a UTF-16 (little-endian) character code, and the resulting string is constructed by concatenating these characters in order.
For example, byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00}) returns "ABC".
Examples[edit]
1 local str = byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00})
2 print(str) -- Output: ABC