ASCII text printing incorrectly

Explanation
I want to print ASCII text in the console (like the one in the example)

Issue
It prints incorrectly as \ is a “magic” character and is not seen

Possible solution
Format the string to show the character

Example:

-- i want to print this
  _____         _   
 |_   _|__  ___| |_ 
   | |/ _ \/ __| __|
   | |  __/\__ \ |_ 
   |_|\___||___/\__|
                    
-- but i get something like this
  _____         _   
 |_   _|__  ___| |_ 
   | | _ / __| __|
   | |  __/__  |_ 
   |_|___||___/__|
                    

could you recommend a possible solution?
Thanks.

1 Like

Make sure it’s a multiline string so escape sequences are not recognized:

local str = [[
  _____         _   
 |_   _|__  ___| |_ 
   | |/ _ \/ __| __|
   | |  __/\__ \ |_ 
   |_|\___||___/\__|
]]
print(str)

… alternatively you could escape each backslash with a preceding backslash if you want

1 Like

Doesn’t work
printed this instead

Now it shows the \ character but keeps printing incorrectly
image

Edit: this is not the “Test” word but it is the same thing

I’ve played around with figure spaces ( U+2007) and using this code should do the trick, in the output it looks like the desired text.

note: the forum editor automatically makes some alterations when pasting text so I put the code in a text file:

lua-ascii-text.txt || https://pastebin.com/HU3DZtb2
(334 Bytes)

copying the text from the file into a script should produce the desired output ±1 (you can move the spaces around if you want, it depends on the font you’re using for the output as well but this should work with the default)
image

I copied figure spaces to my clipboard from here:
https://qwerty.dev/whitespace/

2 Likes

Thanks, you helped me a lot and saved me a lot of time, i will also try to make different words.

EDIT: I found a setting that allows you to replace all spaces with a character of your choice through the site I used with the generation, by inserting a space taken from the site you recommended I got the desired result.

ASCII Text generator

image

image

1 Like