Difference between revisions of "Lua:byteTableToWideString"
								
								Jump to navigation
				Jump to search
				
				
		
 					
								
							
		m  | 
				|||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Lua]]  | [[Category:Lua]]  | ||
| − | '''function''' byteTableToWideString(''Table'') ''':'''   | + | '''function''' byteTableToWideString(''Table'') ''':''' String  | 
| − | Converts a   | + | Converts a table of bytes to a wide string (UTF-16/Unicode), and then to a Lua string.  | 
| − | + | ===Function Parameters===  | |
| − | === Function Parameters ===  | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0"  | 
| − | {|width="85%" cellpadding="10  | ||
!align="left"|Parameter  | !align="left"|Parameter  | ||
!align="left"|Type  | !align="left"|Type  | ||
| Line 12: | Line 11: | ||
|-  | |-  | ||
|Table  | |Table  | ||
| − | |  | + | |Table  | 
| − | |  | + | |A table containing the bytes to convert to a wide string (UTF-16/Unicode).  | 
|}  | |}  | ||
| + | ===Returns===  | ||
| + | String — The resulting string formed from the wide string byte values.  | ||
| − | ==   | + | ===Explanation===  | 
| − | + | 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, <code>byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00})</code> returns <code>"ABC"</code>.  | |
| − | |||
| + | ===Examples===  | ||
| + | <pre>  | ||
| + | local str = byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00})  | ||
| + | print(str) -- Output: ABC  | ||
| + | </pre>  | ||
{{LuaSeeAlso}}  | {{LuaSeeAlso}}  | ||
Latest revision as of 17:42, 11 July 2025
function byteTableToWideString(Table) : String
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]
local str = byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00})
print(str) -- Output: ABC
See also[edit]
Related Functions[edit]
- ansiToUtf8
 - utf8ToAnsi
 - translate
 - readBytes
 - readSmallInteger
 - readInteger
 - readQword
 - readPointer
 - readFloat
 - readDouble
 - readString
 - writeBytes
 - writeSmallInteger
 - writeInteger
 - writeQword
 - writeFloat
 - writeDouble
 - writeString
 - readBytesLocal
 - readIntegerLocal
 - readQwordLocal
 - readPointerLocal
 - readFloatLocal
 - readDoubleLocal
 - readStringLocal
 - writeBytesLocal
 - writeIntegerLocal
 - writeQwordLocal
 - writeFloatLocal
 - writeDoubleLocal
 - writeStringLocal
 - wordToByteTable
 - dwordToByteTable
 - qwordToByteTable
 - floatToByteTable
 - doubleToByteTable
 - stringToByteTable
 - wideStringToByteTable
 - byteTableToWord
 - byteTableToDword
 - byteTableToQword
 - byteTableToFloat
 - byteTableToDouble
 - byteTableToString
 - byteTableToWideString