'How to log unicode characters to the console in JavaScript?

I have a Hungarian statement that I would like to log to the console like this:

console.log('Probléma a működésben.');

But it prints the following:

> Probléma a működésben.

The non ASCII characters are messed up, but I don't think the reason for this is that the console doesn't support Unicode characters, because if I paste the log straight into the console it produces the proper output.

I tested it in Opera, Firefox, Chrome. Happens in Win 8.1 and OSX too, so we can say this is general.

Are there other things that should persist for the proper Unicode console logging, like HTML charset or file encode?



Solution 1:[1]

First way: you have to find your characters in unicode table

console.log( '\u03A9' ); // ?

Second way - use unidecode npm package.

Solution 2:[2]

You can specify the encoding of your file by setting the charset attribute

<script src="script.js" type="text/javascript" charset="utf-8"/>

Solution 3:[3]

No, you must use this table UNICODE en internet, for example, with the character: 'Ã' do this:

string.replace(/\u00c3/g, 'é'); //And you can change all the symbols by what you want

This is with the first character you don't want and so so with the other characters

à == u00c3 and UNICODE

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kas Elvirov
Solution 2 Thibault Sottiaux
Solution 3 Terry Aditya Ildefonso Chagua