diff options
-rw-r--r-- | changelog.md | 3 | ||||
-rw-r--r-- | script/encoder/utf16be.lua | 6 | ||||
-rw-r--r-- | script/encoder/utf16le.lua | 6 |
3 files changed, 9 insertions, 6 deletions
diff --git a/changelog.md b/changelog.md index 60761fa0..1478c320 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # changelog +## 2.4.7 +* `FIX` [#762](https://github.com/sumneko/lua-language-server/issues/762) + ## 2.4.6 `2021-10-26` * `NEW` diagnostic: `redundant-return` diff --git a/script/encoder/utf16be.lua b/script/encoder/utf16be.lua index 179a676d..883ff898 100644 --- a/script/encoder/utf16be.lua +++ b/script/encoder/utf16be.lua @@ -8,7 +8,7 @@ local function tobyte(s, i) end local function char(code) - if code <= 0xffff then + if code <= 0xFFFF then return tochar(code) end code = code - 0x10000 @@ -19,7 +19,7 @@ local m = {} function m.encode(s) local r = {} - for _, c in utf8.codes(s) do + for _, c in utf8.codes(s, true) do r[#r+1] = char(c) end return table.concat(r) @@ -30,7 +30,7 @@ function m.decode(s) local i = 1 while i < #s do local code1 = tobyte(s, i) - if code1 < 0xD800 then + if code1 < 0xFFFF then r[#r+1] = utf8.char(code1) else i = i + 2 diff --git a/script/encoder/utf16le.lua b/script/encoder/utf16le.lua index cfbc33c2..09db87f9 100644 --- a/script/encoder/utf16le.lua +++ b/script/encoder/utf16le.lua @@ -8,7 +8,7 @@ local function tobyte(s, i) end local function char(code) - if code <= 0xffff then + if code <= 0xFFFF then return tochar(code) end code = code - 0x10000 @@ -19,7 +19,7 @@ local m = {} function m.encode(s) local r = {} - for _, c in utf8.codes(s) do + for _, c in utf8.codes(s, true) do r[#r+1] = char(c) end return table.concat(r) @@ -30,7 +30,7 @@ function m.decode(s) local i = 1 while i < #s do local code1 = tobyte(s, i) - if code1 < 0xD800 then + if code1 < 0xFFFF then r[#r+1] = utf8.char(code1) else i = i + 2 |