Difference between revisions of "Lua:byteTableToWideString"

From Cheat Engine
Jump to navigation Jump to search
(Created page with ''''function''' byteTableToWideString(''Table'') Converts a byte table to a widestring and converts that to a string. === Function Parameters === {|width="85%" cellpadding="10%…')
 
m
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''function''' byteTableToWideString(''Table'')
+
[[Category:Lua]]
 +
'''function''' byteTableToWideString(''Table'') ''':''' String
  
Converts a byte table to a widestring and converts that to a string.
+
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%" cellpadding="5%" cellspacing="0" border="0"
 
 
!align="left"|Parameter
 
!align="left"|Parameter
 
!align="left"|Type
 
!align="left"|Type
Line 11: Line 11:
 
|-
 
|-
 
|Table
 
|Table
|table
+
|Table
|The table of bytes to convert
+
|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.
  
== Examples ==
+
===Explanation===
Code:
+
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.
  local bt = { 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x00, 0x00 }
 
  local value = byteTableToWideString(bt)
 
  print(value)
 
  
Output:
+
For example, <code>byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00})</code> returns <code>"ABC"</code>.
  test
 
  
 +
===Examples===
 +
<pre>
 +
local str = byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00})
 +
print(str) -- Output: ABC
 +
</pre>
  
== See also ==
+
{{LuaSeeAlso}}
* [[Lua]]
 
* [[Help_File:Script engine|Script engine]]
 
  
 
=== Related Functions ===
 
=== Related Functions ===
* [[readBytes]]
+
* [[ansiToUtf8]]
* [[readInteger]]
+
* [[utf8ToAnsi]]
* [[readQword]]
+
* [[translate]]
* [[readPointer]]
+
{{ReadWriteMemory}}
* [[readFloat]]
 
* [[readDouble]]
 
* [[readString]]
 
* [[writeBytes]]
 
* [[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]]
 

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

Parameter Type Description
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, byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00}) returns "ABC".

Examples

local str = byteTableToWideString({0x41, 0x00, 0x42, 0x00, 0x43, 0x00})
print(str) -- Output: ABC

See also

Lua
Script Engine

Related Functions

Read Functions
readBytes
readSmallInteger
readInteger
readQword
readPointer
readFloat
readDouble
readString
Read Functions (Local Process)
readBytesLocal
readIntegerLocal
readQwordLocal
readPointerLocal
readFloatLocal
readDoubleLocal
readStringLocal
Write Functions
writeBytes
writeSmallInteger
writeInteger
writeQword
writeFloat
writeDouble
writeString
Write Functions (Local Process)
writeBytesLocal
writeIntegerLocal
writeQwordLocal
writeFloatLocal
writeDoubleLocal
writeStringLocal
Byte Table Conversions (Value → Byte Table)
wordToByteTable
dwordToByteTable
qwordToByteTable
floatToByteTable
doubleToByteTable
stringToByteTable
wideStringToByteTable
Byte Table Conversions (Byte Table → Value)
byteTableToWord
byteTableToDword
byteTableToQword
byteTableToFloat
byteTableToDouble
byteTableToString
byteTableToWideString