summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-11-10 21:19:05 +0000
committerKarl Berry <karl@freefriends.org>2021-11-10 21:19:05 +0000
commit5dd4e1f78df7dc76088ca746c7d08c6a6647e177 (patch)
tree6a882f77442761762eefe96f832f9b009064bd74 /Master/texmf-dist/scripts
parentd4a63dd0c855396785fc90d176b999507e51ce3e (diff)
lua-uca (10nov21)
git-svn-id: svn://tug.org/texlive/trunk@61023 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-xMaster/texmf-dist/scripts/lua-uca/lua-uca-collator.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/Master/texmf-dist/scripts/lua-uca/lua-uca-collator.lua b/Master/texmf-dist/scripts/lua-uca/lua-uca-collator.lua
index c009bc98689..258b2a12e4b 100755
--- a/Master/texmf-dist/scripts/lua-uca/lua-uca-collator.lua
+++ b/Master/texmf-dist/scripts/lua-uca/lua-uca-collator.lua
@@ -2,6 +2,11 @@
local math = require "math"
local tailoring_lib = require "lua-uca.lua-uca-tailoring"
local reordering_table = require "lua-uca.lua-uca-reordering-table"
+local uni_normalize
+-- in LuaTeX, load the lua-uni-normalize library
+if kpse then
+ uni_normalize = require "lua-uni-normalize"
+end
local collator = {}
collator.__index = collator
@@ -213,9 +218,20 @@ function collator:compare(a, b)
return #a < #b
end
+local codepoints_cache = {}
+
function collator:string_to_codepoints(a)
+ if codepoints_cache[a] then return codepoints_cache[a] end
+ -- try unicode normalization, if it is available
+ -- it uses libraries available in LuaTeX, so it doesn't work with
+ -- stock Lua
+ local normalized = a
+ if uni_normalize then
+ normalized = uni_normalize.NFC(a)
+ end
local codepoints = {}
- for _, code in utf8.codes(a) do codepoints[#codepoints+1] = code end
+ for _, code in utf8.codes(normalized) do codepoints[#codepoints+1] = code end
+ codepoints_cache[a] = codepoints
return codepoints
end