word30210/luau_confusables
v0.1.0 Β·
a confusable character checker
luau-confusable
luau-confusable is a confusable character checker I ported from luau-lang/luau/Ast/src/Confusables.cpp.
Example
const confusables = require("@path/to/luau_confusable")
const input = "πorπ"
local corrected_input = ""
for _, codepoint in utf8.codes(input) do
local confusable = confusables(codepoint)
if confusable then
print(`Unicode character U+{ string.format("%X", codepoint) } (did you mean '{ confusable }'?)`)
corrected_input ..= confusable
else
corrected_input ..= utf8.char(codepoint)
end
end
print(`Hello, { corrected_input }!`) -- Hello, Word!