Lua Code:
["bleakrock/bleakrockvillage_base"] = {"Bleakrock Village", "Ödfels^N,in", "\xd6dfels^N,auf", "\xEF\xBF\xBDdfels^N,auf", "village de Morneroc^md",},
I have some map names with escape sequences in them. One is a BOM sequence.
Lua Code:
function Harvest.GetNewMapName(mapName)
local result = nil
for newMapName, translations in pairs(Harvest.mapSystem) do
if Harvest.contains(translations, mapName) then
if result then
return nil --there are more than one possible maps, skip to prevent wrong data
else
result = newMapName
end
end
end
return result
end
That function is used to look for possible results. It will find "Ödfels^N,in" but not "\xd6dfels^N,auf" and "\xEF\xBF\xBDdfels^N,auf" because I think the string is being treated as a literal match, not as a unicode string.
Lua Code:
function Utf8to32(utf8str)
assert(type(utf8str) == "string")
local res, seq, val = {}, 0, nil
for i = 1, #utf8str do
local c = string.byte(utf8str, i)
if seq == 0 then
table.insert(res, val)
seq = c < 0x80 and 1 or c < 0xE0 and 2 or c < 0xF0 and 3 or
c < 0xF8 and 4 or --c < 0xFC and 5 or c < 0xFE and 6 or
error("invalid UTF-8 character sequence")
val = bit32.band(c, 2^(8-seq) - 1)
else
val = bit32.bor(bit32.lshift(val, 6), bit32.band(c, 0x3F))
end
seq = seq - 1
end
table.insert(res, val)
table.insert(res, 0)
return res
end
I googled that but i'm not really trying to check for valid UTF-8 chars, and amke sure there aren't any errors. What I am wondering is what simple command do I use to take a string like "\xEF\xBF\xBDdfels^N,auf" and match it with "�dfels^N,auf". Where "�" is the BOM sequence.
When "\xEF\xBF\xBDdfels^N,auf" == "�dfels^N,auf" then then the result would be true.
Lua Code:
string.escape(string1, string2)
Is there something like above where string1 = "\xEF\xBF\xBDdfels^N,auf" and string2 = "�dfels^N,auf" so then it's true?