summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--changelog.md4
-rw-r--r--script/encoder/utf16be.lua10
-rw-r--r--script/encoder/utf16le.lua10
4 files changed, 15 insertions, 11 deletions
diff --git a/README.md b/README.md
index bc30905e..78d2120b 100644
--- a/README.md
+++ b/README.md
@@ -102,7 +102,7 @@ Please [help me][en-US] improve the quality of `en-US`.
## Setting
* In VSCode: Just use the setting of VSCode.
-* Standalone: See https://github.com/sumneko/lua-language-server/wiki/Setting-without-VSCode
+* Standalone: See https://github.com/sumneko/lua-language-server/wiki/Setting
## Credit
diff --git a/changelog.md b/changelog.md
index 60761fa0..19520163 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,9 @@
# changelog
+## 2.4.7
+`2021-10-27`
+* `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..5fc19b2c 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,13 +30,13 @@ function m.decode(s)
local i = 1
while i < #s do
local code1 = tobyte(s, i)
- if code1 < 0xD800 then
- r[#r+1] = utf8.char(code1)
- else
+ if code1 >= 0xD800 and code1 < 0xE000 then
i = i + 2
local code2 = tobyte(s, i)
local code = 0x10000 + ((code1 - 0xD800) << 10) + ((code2 - 0xDC00) & 0x3FF)
r[#r+1] = utf8.char(code)
+ else
+ r[#r+1] = utf8.char(code1)
end
i = i + 2
end
diff --git a/script/encoder/utf16le.lua b/script/encoder/utf16le.lua
index cfbc33c2..d51b4cfb 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,13 +30,13 @@ function m.decode(s)
local i = 1
while i < #s do
local code1 = tobyte(s, i)
- if code1 < 0xD800 then
- r[#r+1] = utf8.char(code1)
- else
+ if code1 >= 0xD800 and code1 < 0xE000 then
i = i + 2
local code2 = tobyte(s, i)
local code = 0x10000 + ((code1 - 0xD800) << 10) + ((code2 - 0xDC00) & 0x3FF)
r[#r+1] = utf8.char(code)
+ else
+ r[#r+1] = utf8.char(code1)
end
i = i + 2
end