[英]Using German characters (e.g. Umlaut) in HTML
I am trying to encode German characters in html. 我正在尝试在html中编码德语字符。 I just want to use the special character codes.
我只想使用特殊的字符代码。 For the Umlaut, I've tried using both
Ü
对于Umlaut,我尝试同时使用
Ü
and Ü
和
Ü
and neither renders properly. 而且都无法正确渲染。 What am I doing wrong?
我究竟做错了什么? Thanks.
谢谢。
This is for a Squarespace site, and I am inserting Javascript into their Code Injection page, into the footer. 这是针对Squarespace网站的,我将Javascript插入其“代码注入”页面的页脚中。 I am using Javascript to write a German word on the page.
我正在使用Javascript在页面上写德语单词。 The relevant part of my code looks like the below.
我的代码的相关部分如下所示。 And the problem is that this simply renders "& U uml;ber' (space added by me because the umlaut renders properly on Stack Overflow without it) on the page rather than Uber with an umlaut. Thanks!
问题是,这只会在页面上呈现“&U uml; ber”(我添加了空格,因为没有它,它会在Stack Overflow上正确呈现,因为它不是在Uber上使用了变音符号。
var strings = {
'About': {
'de': 'Über'
},
Try using Ü
尝试使用
Ü
for the German character Ü. 代表德语字符Ü。
You need to escape special characters in HTML, unless... 您需要转义 HTML中的特殊字符 ,除非...
You address the encoding issue on a document-wide level by adding the following line of code at the beginning of the <head>
section: 通过在
<head>
部分的开头添加以下代码行,可以解决整个文档级别的编码问题:
<meta charset="utf-8">
Then you don't need to escape special characters individually. 这样,您就无需单独转义特殊字符。
Further reading: 进一步阅读:
UPDATE 1 (Javascript) 更新1(Javascript)
UPDATE 2 (Squarespace) 更新2(平方空间)
This solution worked for me. 这个解决方案对我有用。 Use the hex code but eliminate the &# from the beginning and add a /
使用十六进制代码,但从头开始消除&#并添加/
So, to render the word "Über" within Javascript in Squarespace, use /xdcber 因此,要在Squarespace中的Javascript中渲染单词“Über”,请使用/ xdcber
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.