Home > OS >  Converting Ascii Text Art To UTF-8
Converting Ascii Text Art To UTF-8

Time:10-22

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
  \___/|_||_\___|
               

CodePudding user response:

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.

  • Related