Copy Link
Add to Bookmark
Report

NULL mag Issue 06 24 ANSI to text

eZine's profile picture
Published in 
null magazine
 · 26 Dec 2020

  




i don't know what got me... but i want to build a local ansi database!
i want to have all available ansi art in my hdd, categorized with tags
and even a search engine capability to search the text into the ansis.

to make this... i am gonna build an sqlite3 database that will contain
the text from the ansi images. this way with an sql string i could
make an easy search engine. so... how you put all ansis into an sqlite
base? by getting rid of all the non usable parts of the ansi, which
are a lot!

we don't need:
+ escape codes
+ ascii symbols that are non letters/numbers
+ sauce data
+ duplicate text
+ strings that are longer than ex.20chars, cause
these may be part of the graphics and not actual
text.

the simplest way is to use bash. with this oneliner we can transform a
60Kb ansi, into 100bytes text file, that will contain only the usable
/ searchable text.

cat "$1" | sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' | \
strings -e s | tr " " "\n" | sed '/^$/d'| sed 's/[^A-Z0-9]//ig' \
| uniq -u| sed 's/SAUCE//g' | sed -r 's/\b\w{20,}\s?\b//g' \
|sed -r '/^.{,3}$/d'| tr "\n" "," > "$2"

it will remove all unnecessary chars and keep only the readable
strings, which will form our base... more on the search engine... in
next issues.




← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT