Search code examples
asciinano

How does nano represent special ASCII characters compared to Sublime?


I'm writing up a game in P5.js which draws emojis to a canvas.

I was originally using the sublime text editor to copy paste special ASCII characters straight into the code which works fine, but I now only have access to nano which doesn't seem to accept this way.

Nano manages to convert what I have already done, into some different characters. Presumably, this is Nano's way of interpreting those ASCII characters.

I am using this because phones and browsers now automatically convert these ASCII characters into emojis.

Example:

the heart emoji is converted from the special ASCII character in sublime, to âö¥ in Nano automatically when you open the file.

I am wondering if there is a reference sheet somewhere where I can find other conversions for emojis I would like to use.


Solution

  • Just forget ASCII. HTML uses Unicode characters. JavaScript uses Unicode's UTF-16 encoding. Your files might use Unicode's UTF-8 encoding.

    ASCII does not have the character ♥.

    Special characters in JavaScript include quote, double quote, backslash, and similar. If you wish or need to, you can escape UTF-16 code units using the "\uABCD" notation. Special characters in HTML are <, >, & and similar. If you wish or need to, you can use named or numeric character entity references like &amp; or &#x1f6b2;

    ♥ is not special; It's just a character with no particular purpose, just like tens of thousands of others.

    Conversions from typed characters to other characters is an input function, typically performed by the OS or other input software. So, that's generally outside the scope of HTML and JavaScript.

    A text file has an encoding. Some programs help you when opening a file by guessing; You then have to correct them.

    It's generally easiest if all files are UTF-8. Sometimes a BOM helps, sometimes not. The fundamental rule about character encodings is to read using the encoding that was used to write with.

    The list of Unicode characters is here. There several other good sites for searching and coding including http://www.fileformat.info/.