Page 1 of 1

Write String Zero Terminated

Posted: Sun Aug 21, 2022 2:32 am
by bbfox

Code: Select all

function writeZeroTerminatedString(address, text, isUnicode)
  if isUnicode then
    writeWideString(address, text .. "\0")
  else
    writeString(address, text .. "\0")
  end
end

Test sample:

Code: Select all

local addr = 0x12345678 -- change yourself

-- Ascii string
writeZeroTerminatedString(addr, "Hello! another world ASCII!", false)

-- Unicode string
writeZeroTerminatedString(addr, "是在哈囉,另一個世界?", true)

--Poor man's debugger
print("ASCII:", readString(addr))
print("Unicode:", readWideString(addr))