-- @runtimes lua54 luajit --- 演示:转义、\0、长括号字符串与字节访问。 local M = {} --- @return table { nul_length = integer, first_byte = integer, raw_length = integer } function M.run(log) log = log or print local binary = "A\0B" local raw = [[line1 line2]] log(("nul_length=%d"):format(#binary)) log(("first_byte=%d"):format(string.byte(binary, 1))) log(("raw_length=%d"):format(#raw)) log(("raw_has_newline=%s"):format(tostring(raw:find("\n", 1, true) ~= nil))) return { nul_length = #binary, first_byte = string.byte(binary, 1), raw_length = #raw } end if not ... then M.run() end return M