问题描述
我的网页包含德语字符,并且我在
HTML标记之间键入了文本,但浏览器以不同方式查看某些字符。我需要在HTML中包含任何内容以正确显示德文字符吗?
< label> ausgefüllt< / label>
不幸的是,您需要一些基本的解释即使大多数程序员也不理解。
像HTML页面这样的文件会以字节序列的形式在互联网上保存和传输,但您希望它们显示为字符。为了将字节转换为字符,您需要一套称为的规则。不幸的是,历史上出现了许多不同的字符编码来处理不同的语言。它们中的大多数都基于美国的编码,但只要字符超出ASCII如,您需要非常小心使用哪种编码。
问题的根源在于,为了正确解码HTML文件,浏览器需要知道使用哪种编码。您可以通过以下几种方式来说明:
- ,如果您使用
因此,您需要选择一种编码,使用该编码保存HTML文件,并确保您至少使用上面列出的方法之一声明了该编码(并且如果您使用了多个编辑器,则确定它们同意)。至于使用什么编码,德国人通常使用,但是一个很好的选择,它可以处理任何类型的非ASCII字符同一时间。
My pages contain German characters and I have typed the text in between theHTML tag, but the browser views some characters differently. Do I need to include anything in HTML to properly display German characters?
<label> ausgefüllt </label>
It seems you need some basic explanations about something that unfortunately even most programmers don't understand properly.
Files like your HTML page are saved and transmitted over the Internet as a sequence of bytes, but you want them displayed as characters. In order to translate bytes into characters, you need a set of rules called a character encoding. Unfortunately, there are many different character encodings that have historically emerged to handle different languages. Most of them are based on the American ASCII encoding, but as soon as you have characters outside of ASCII such as German umlauts, you need to be very careful about which encoding you use.
The source of your problem is that in order to correctly decode an HTML file, the browser needs to know which encoding to use. You can tell it so in several ways:
So you need to pick one encoding, save the HTML file using that encoding, and make sure that you declare that encoding in at least one of the ways listed above (and if you use more than one make damn sure they agree). As for what encoding to use, Germans usually use ISO/IEC 8859-15, but UTF-8 is a good alternative that can handle any kind of non-ASCII characters at the same time.
这篇关于我怎样才能在HTML中正确显示德文字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!