Is writing <meta charset=utf-8 />
in an HTML file (being edited by Emacs) sufficient, or do I also need to specify -*- coding: utf-8 -*-
on the first line?
In other words, do I have to write
<!-- -*- coding: utf-8 -*- -->
<!DOCTYPE html>
<head>
<meta charset=utf-8 />
</head>
<body>
<p>你好,世界!</p>
<p>Xin chào thế giới</p>
</body>
or is it sufficient to write
<!DOCTYPE html>
<head>
<meta charset=utf-8 />
</head>
<body>
<p>你好,世界!</p>
<p>Xin chào thế giới</p>
</body>
to signal to Emacs that I'd like the file to be saved in utf-8
?
I'm using web-mode.el
for HTML pages (because it is the nicest way at this time to edit an HTML page that may also contain CSS and JS code).
And if you know the answer, you won't mind my trying to sneak a second question here: Why is Emacs (25.3.1) unable to properly encode display the Vietnamese text above (which SO handles just fine), even though the same Emacs handles the Chinese text with no difficulty?
emacs -Q
, version 26.1 (build 2, x86_64-pc-linux-gnu) displays the chinese characters in the html document just fine on my box. – Tobias Jun 21 at 16:23