discord-bot/HomoglyphConverter
13xforever d4e78d1b1b
upgrade solution to net9.0
this bumps docker image base to ubuntu 24.04
2024-11-13 13:43:33 +05:00
..
confusables.txt update confusables from 15.1.0 to 16.0.0 2024-10-15 18:40:12 +05:00
HomoglyphConverter.csproj upgrade solution to net9.0 2024-11-13 13:43:33 +05:00
Normalizer.cs update code with new language and api features 2023-04-21 02:05:59 +05:00
readme.md replace runtime builder with source generator for unicode confusables 2021-01-28 20:11:26 +05:00

Homoglyph Converter

This is a straight up implementation of the recommended confusable detection algorithm. It is mainly used to check for mod impersonation.

You can get the latest version of the mappings from the Unicode.org. You'll need to manually gzip it for embedding in the resources.

Code is split in two parts:

  • Builder will load the mapping file from the resources and will build the mapping dictionary that can be used to quickly substitute the character sequences.

    One gotcha is that a lot of the characters are from the extended planes and require use of surrogate pairs, so we convert them to UTF32 and store as uint.

  • Normalizer implements the mapping and reducing steps of the algorithm