User copy paste and send data in following format: "๐๐ ๐ง๐ช ๐๐๐๐๐๐" I need to convert it into plain txt (we can say ascii chars) like 'jovy debbie' It comes in different font and format: ex: '๐ฑ๐๐๐๐๐ ๐ซ๐๐๐๐' '๐ถ๐๐๐๐๐๐ข๐ ๐ฝ๐๐๐๐๐ ๐ป๐๐๐๐๐'
Any Help will be Appreciated, I already refer other stack overflow question but no luck :(
Those letters are from theMathematical Alphanumeric Symbols block.
Since they have a fixed offset to their ASCII counterparts, you could use tr
to map them, eg:
"๐๐ ๐ง๐ช ๐๐๐๐๐๐".tr("๐-๐ซ", "a-z")
#=> "jovy debbie"
The same approach can be used for the other styles, eg
"๐ฑ๐๐๐๐๐ ๐ซ๐๐๐๐".tr("๐-๐๐จ-๐", "a-zA-Z")
#=> "Jenica Dugos"
This gives you full control over the character mapping.
Alternatively, you could try Unicode normalization . The NFKC / NFKD forms should remove most formatting and seem to work for your examples:
"๐๐ ๐ง๐ช ๐๐๐๐๐๐".unicode_normalize(:nfkc)
#=> "jovy debbie"
"๐ฑ๐๐๐๐๐ ๐ซ๐๐๐๐".unicode_normalize(:nfkc)
#=> "Jenica Dugos"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.