pythonascii-art

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

re.split

How could I convert..

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

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.