overexchange
overexchange

Reputation: 1

How to insert these non-ascii characters as html content?

Any non-ascii representation is written as &#xYYYY.

As per below code,

enter image description here

Editor is Sublime Text.

How do I represent these emoticons in html?

Upvotes: 1

Views: 1493

Answers (3)

Simon
Simon

Reputation: 3717

As long as you save the file you're editing using the UTF-8 character encoding, and make sure it is delivered with a suitable content type header, such as Content-Type: text/html; charset=utf-8 you don't need to do anything at all.

Another option, as others have noted, is adding them as HTML entities instead. In order to do that you would need to know their character codes. How to do that differs between different environments, but there are multiple questions on SO about that.

Here's how you could do it in Python (Python 3, you'd need to use u"" strings in earlier versions):

chars = [
    "😀",
    "😐",
    "😳",
    "😫",
    "💩"
]

for char in chars:
    print("{}: &#{:02x};".format(char, ord(char)))

Upvotes: 1

catzilla
catzilla

Reputation: 1981

You can represent Emoticons in html as its unicode symbol formatted as 򪪪 (some unicode list)

<div>&#x1F601;</div>

I am using sublime text as editor and when you see it on browser it should look like these:

enter image description here

Upvotes: 0

hertg
hertg

Reputation: 173

I found this Sublime Text 3 Plugin to insert emojis into the editor.

https://packagecontrol.io/packages/Emoji

Is this what you are looking for?

Upvotes: 2

Related Questions