forked from FakeFishGames/Barotrauma
-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Labels
featureNew feature or requestNew feature or request
Description
lua itself doesn't recognize some unicode sequences like \u6211\u6212\u6213\u1362\u1462\u1562 <=> 我戒戓።ᑢᕢ, for example:
local result = string.gsub("我戒戓።ᑢᕢ", '[%z\1-\31\\"]', function (c)
return "\\" .. string.format("u%04x", c:byte())
end)
print(result)
-- output:
-- \u003f\u003f\u003f
the output wasn't what we expected, so lua's pure json library (such as json.lua by rxi) doesn't work well due to single-byte constraints for string functions.
However, I found a better Json tool named JsonTableConverter at MoonSharp that (de)serialization between table and json is done entirely in C#, doesn't produce this problem, and its performance is about 15 times higher than the pure lua json library, but we need to manually escape "\/"
of course we can also use JsonTableConverter directly via LuaUserData, but it seems a little weird to use MoonSharp to register a type under MoonSharp.
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request