summaryrefslogtreecommitdiff
path: root/script/client.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/client.lua')
-rw-r--r--script/client.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/script/client.lua b/script/client.lua
index 4d338016..4d39cd0d 100644
--- a/script/client.lua
+++ b/script/client.lua
@@ -59,6 +59,23 @@ function m.getAbility(name)
return current
end
+function m.getOffsetEncoding()
+ if m._offsetEncoding then
+ return m._offsetEncoding
+ end
+ local clientEncodings = m.getAbility 'offsetEncoding'
+ if type(clientEncodings) == 'table' then
+ for _, encoding in ipairs(clientEncodings) do
+ if encoding == 'utf-8' then
+ m._offsetEncoding = 'utf-8'
+ return m._offsetEncoding
+ end
+ end
+ end
+ m._offsetEncoding = 'utf-16'
+ return m._offsetEncoding
+end
+
local function packMessage(...)
local strs = table.pack(...)
for i = 1, strs.n do
@@ -255,6 +272,7 @@ function m.init(t)
m.client(t.clientInfo.name)
nonil.disable()
lang(LOCALE or t.locale)
+ converter.setOffsetEncoding(m.getOffsetEncoding())
hookPrint()
end