Reputation: 667
I was wondering how to make the heart sign or "♥"
in Lua, I have tried \003
because that is the ASCII code for it, but it does not print it out.
Upvotes: 1
Views: 558
Reputation: 20812
This has little to do with Lua.
You need to find out which character set and encoding is used in your environment and select a font that supports ♥ in that encoding.
Then you need to use an editor for your Lua script that saves in that encoding. If that part is not possible then you can determine the byte sequence required, code it as numeric escapes in a literal string and save in a compatible encoding such as CP437. For example, if you are outputting to a UTF-8 processor, "\xE2\x99\xA5".
Keep in mind that a Lua string is a counted sequence of bytes. It's up to you and your editor to put the right bytes in in the file, it's up to your environment (e.g., console) to interpret those bytes in a particular character encoding, and up to the font to display the glyph.
In a Windows console, you can select the Lucinda Console font, chcp 65001
to use UTF-8 and use Lua 5.1 like this: lua -e "print('\226\153\165')"
. As a comparison, chcp 437
to use IBM437 and use Lua 5.1 like this: lua -e "print('\003')"
.
Upvotes: 3