Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Converting Ascii Text Art To UTF-8

I am trying to convert a text-based ascii art into utf-8, whilst doing so I’ve ran into multiple technical problems using these methods

find

  • This method is a simpler approach, but it doesn’t work because of many reasons, character arrangement, and clustered characters. therefore it won’t work
  • I actually think it would work if python was my first language

re.split

  • Honestly, I don’t know why I attempted to use this, the method re uses to split multiple items from a string, but I realized that it wouldn’t work because of character placement.

How could I convert..

   ___           
  / _ \ _ _  ___ 
 | (_) | ' \/ -_) ->> One
  \___/|_||_\___|
               

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can’t.
Unless your ASCII art will use always the same letters, drawn in the same way – there are no rules that can be made to recognize the text deterministically.

And even if the letters are always drawn in the same way, that is, an "O" will always be comprised of the exact same characters in your example, it could be a complicated code. It could be a bit simpler if the letters are "monospaced", and do not touch each other. In your example, the O and n share a "|": that makes this text more complicated to be parsed algorithmically.

Ultimatelly you will have to resort to convert your ASCII art to an image, and apply OCR tools to try and recognize the characters. However, the fact that they are very stilized will make OCRing it hard as well.

All in all: if you have a fixed amount of input ASCII art, you could just make a dictionary mapping each art to the text: this is the more feasible way, even if you are close to 10 thousand different designs.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading