0

I would like to store a couple of country flags into my PostgreSQL database. But when my website's view file fetches the flag data the source output looks like this text <td>&amp;#127482;&amp;#127480;</td> and not the flag Emoji.

INSERT INTO mytable (country, flag) VALUES ('United States', '&#127482;&#127480;');

I tried to create the flag column with these Data Types:

  • VARCHAR(150)
  • TEXT

But the web browser's source output doesn't seem to give me the visual Emoji. I DuckDuckGo some websites and PostgreSQL docs, and read some other threads on this issue. But I can't grasp their answers and understand how to implement this.

Help please.

It works when I hard code the Emojis directly into my HTML files but not when I save it to Postgres and fetches it with EJS.

https://www.quackit.com/character_sets/emoji/emoji_v3.0/emoji_icons_flags.cfm

https://www.w3schools.com/charsets/ref_emoji.asp

piggy
  • 83
  • 1
  • 3
  • 11
  • 1
    I suspect this is ejs escaping the string. Assuming you have the html string in a variable, the correct template syntax for you might be ```<%- your_variable %>``` as discussed here: https://stackoverflow.com/questions/10326950/render-a-variable-as-html-in-ejs I think Postgres has nothing to do with it. – Bjarni Ragnarsson Feb 04 '21 at 08:23

1 Answers1

0

Hi @BjarniRagnarsson you are correct I just took a look at Tags chapter and tried it out. https://ejs.co/

Before = Incorrect, <%= your_variable %>

After = Correct, <%- your_variable %>

But it seems I only get the visual Emoji as intended on Firefox not in Chrome. Guess I have to resort to using image files for my flags in order to display it correctly on all web browsers.

piggy
  • 83
  • 1
  • 3
  • 11