rsl / stringex

Some [hopefully] useful extensions to Ruby’s String class. It is made up of three libraries: ActsAsUrl [permalink solution with better character translation], Unidecoder [Unicode to Ascii transliteration], and StringExtensions [miscellaneous helper methods for the String class].
MIT License
984 stars 158 forks source link

Feature: unicode characters to ascii fuzzy equivalents #207

Open gabriel opened 1 year ago

gabriel commented 1 year ago

Thanks for this library!

"𝔭𝔬𝔱𝔦𝔬𝔫 𝔰𝔢𝔩𝔩𝔢𝔯".to_ascii
=> "?????? ??????"

Would be a nice enhancement for this to output:

"𝔭𝔬𝔱𝔦𝔬𝔫 𝔰𝔢𝔩𝔩𝔢𝔯".to_ascii
=> "potion seller"

There is a unicode-tools python library that can handle this, e.g.: https://unicode.scarfboy.com/?s=%F0%9D%94%AD%F0%9D%94%AC%F0%9D%94%B1%F0%9D%94%A6%F0%9D%94%AC%F0%9D%94%AB+%F0%9D%94%B0%F0%9D%94%A2%F0%9D%94%A9%F0%9D%94%A9%F0%9D%94%A2%F0%9D%94%AF