在具有charset = utf-8的HTML文件中,我仍然需要用& auml;替换变音符号吗? [英] In a HTML file with charset=utf-8, do I still need to replace umlauts with ä?

查看:89
本文介绍了在具有charset = utf-8的HTML文件中,我仍然需要用& auml;替换变音符号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我过去在HTML文件中使用德国变音符时,总是根据此表.

Whenever I used a German umlaut in a HTML file in the past, always I replaced it by ä, ö etc. according to this table.

那时我不知道编码,也从未考虑过.
我只是知道"当我只使用äö等时,其他国家/地区的许多计算机将无法正确显示变音符号.

I had no idea about encoding then, nor did I ever think about it.
I just "knew" that when I would just use ä, ö etc. instead, many computers in other countries wouldn't be able to display the umlauts correctly.

当我通过放置 <meta charset="utf-8"> 将UTF-8编码的HTML文件的字符集设置为UTF-8时,进入标题,我 still 是否需要将ä替换为&auml;,将ö替换为&ouml;,依此类推?

When I set the charset of an UTF-8 encoded HTML file to UTF-8 by putting <meta charset="utf-8"> into the header, do I still need to replace ä by &auml;, ö by &ouml; and so on?

例如:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>ÄÖÜäöüß</title>
  </head>
  <body>
    ÄÖÜäöüß
  </body>
</html>

当我将其保存在计算机上的UTF-8编码的HTML文件中并在浏览器中查看时,所有变音符号都会正确显示.
但是我在德国,并且我的机器上的所有东西都是德语,所以当然我的机器能够正确显示德国变音符号.

When I save this in an UTF-8 encoded HTML file on my machine and view it in a browser, all umlauts are displayed correctly.
But I'm in Germany and everything on my machine is in German, so of course my machine is able to properly display German umlauts.

我阅读了Joel的每个软件开发人员绝对绝对肯定要了解Unicode和字符集的绝对最低要求(没有借口!),但是这种编码方式对我来说是全新的.

I read Joel's The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!), but this encoding stuff is all new to me.

据我对编码,UTF-8和设置字符集的了解,我怀疑在UTF-8编码的HTML文件中设置<meta charset="utf-8">意味着我不需要不再使用&auml;等.
但是我找不到确切的来源.

From what I understand about encoding, UTF-8 and setting charsets, I'm suspecting that setting <meta charset="utf-8"> in an UTF-8 encoded HTML file means I do not need to use &auml; etc. anymore.
But I couldn't find a source that definitely says so.

推荐答案

当我通过将<meta charset="utf-8">放在标题中将HTML文件的字符集设置为UTF-8时

When I set the charset of a HTML file to UTF-8 by putting <meta charset="utf-8"> into the header

这不会设置字符编码.它声明您正在使用哪种字符编码.您还必须确保使用该编码保存HTML.

That doesn't set the character encoding. It declares which character encoding you are using. You must also make sure you are saving the HTML using that encoding.

然后给出:

我是否还需要用&auml;替换ä,用&ouml;替换ö,依此类推?

do I still need to replace ä by &auml;, ö by &ouml; and so on?

不.只有在HTML中具有特殊含义的字符(<>&"'…在某些情况下所有这些都具有特殊含义)才必须替换为字符引用.

No. Only characters with special meaning in HTML (<, >, &, ", ' … all of which only have special meaning in some contexts) must be replaced with character references.

这篇关于在具有charset = utf-8的HTML文件中,我仍然需要用&amp; auml;替换变音符号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆