A Common Lisp library for handling unicode homoglyphs.
The homoglyphs db format is as is used by https://github.com/codebox/homoglyph. The function (make-homoglyph-db-from-uri)
without the optional uri parameter will default to loading that project's database directly from github.
I recognize that most of the work involved is in generating and maintaining the database. If you use this library then you'll most likely want to use the one generated by @codebox - so kudos are due that way, too.
Tested with SBCL and CLISP - I think it should be pretty close to modern "standard" Common Lisp, but YMMV.
CL-USER> (push #p"/home/ghard/src/cl-homoglyph/" ql:*local-project-directories*)
CL-USER> (ql:quickload :cl-homoglyph)
To load "cl-homoglyph":
Load 1 ASDF system:
cl-homoglyph
; Loading "cl-homoglyph"
(:CL-HOMOGLYPH)
CL-USER> (asdf:test-system 'cl-homoglyph)
T
CL-HOMOGLYPH> (setf *homoglyph-db* (make-homoglyph-db-from-uri)) ; this loads the homoglyph data from https://raw.githubusercontent.com/codebox/homoglyph/master/raw_data/char_codes.txt
(#<HASH-TABLE :TEST EQL :COUNT 4317 {10048BFA43}>
#<HASH-TABLE :TEST EQL :COUNT 1852 {10048D3EC3}>)
CL-HOMOGLYPH> (homoglyphise-string "Rivon orin roviot torilla")
"๐ก๐ข๐o๐โจo๐ณำ๐โจ๐ปo๏ฝโ
ฐo๐โฏ๏ฝo๊ฎโ
ฐll๐บ"
CL-HOMOGLYPH> (let* ((tstr "Mieleni minun tekevi, aivoni ajattelevi.")
(hstr (homoglyphise-string tstr)))
(list tstr hstr (homoglyph-str-p tstr hstr)))
("Mieleni minun tekevi, aivoni ajattelevi."
"โณ๐ถ๏ฝ
lโฎ๐ฏโ
โ
๏ฝ๐๏ฝ๐ฆีธโ๐โ
๐๐๐๐โโฉฮฑแฅ๐o๐ซหโ๐๐ง๐ฎ๐๐๐ขl๐ฎ๐๐๊" T)