You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the function icu_bidi_runs there is a calculation to reduce the length of a run based on 2-part UTF-16 codes. There is a bug in this calculation. The loop walks forward reducing the length each time a trailing character is found. But this means that if there is more than one trailing character in a string, then the final character(s) will not be tested and the length may come out too long.
I suggest running the loop backwards.
The text was updated successfully, but these errors were encountered:
Confirmed. Here's a spec test. Length is currently coming out as 4:
SILE = require("core/sile")
local icu = require("justenoughicu")
describe("SILE.linebreak", function()
local chars = { 0x10000, 0x10001, 0x10002 }
local utf8string = ""
for i = 1,#chars do
utf8string = utf8string .. SU.utf8char(chars[i])
end
it("should be the right length in UTF8", function()
assert.is.equal(#utf8string, 12)
end)
it("should be the right length from ICU", function()
local res = icu.bidi_runs(utf8string, "LTR")
assert.is.equal(res.length, 3)
end)
end)
In the function icu_bidi_runs there is a calculation to reduce the length of a run based on 2-part UTF-16 codes. There is a bug in this calculation. The loop walks forward reducing the length each time a trailing character is found. But this means that if there is more than one trailing character in a string, then the final character(s) will not be tested and the length may come out too long.
I suggest running the loop backwards.
The text was updated successfully, but these errors were encountered: