简体   繁体   English

在HTML中使用德语字符(例如Umlaut)

[英]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.

相关问题 将OpenLayers地图从例如英语翻译成德语 - Translate OpenLayers map from e.g. English to German 如何通过JavaScript显示德语Umlaut字符? - How to display German Umlaut characters through JavaScript? json2html如何处理json键中的特殊字符(例如@) - json2html how to deal with special characters (e.g. @) in json keys 条形图中的提示未显示用html特殊字符括起来的文本,例如<cable> - the hint in bar chart is not showing the text enclosed in html special characters e.g.<cable> 禁止在所有输入文本框中使用jquery键入少量字符,例如“&lt;”,“&gt;” - Disallow typing of few of characters e.g.'<', '>' in all input textboxes using jquery 在JavaScript中使用正则表达式检查模式重用(例如,在字符串中声明两次的相同字符序列) - Using regular expressions in JavaScript for checking pattern reuse (e.g. the same sequence of characters declared twice in string) 如何在不访问 HTML 的情况下拆分 HTML 页面,例如使用 split.js? - How to split a HTML page without access to the HTML, e.g. using split.js? 在本地运行 html 文件时需要使用 axios 的想法(例如浏览器中的 file:// 路径) - Need ideas for using axios when running html file locally (e.g. file:// path in browser) 如何使用Javascript检查html中的父元素是否是特定的标记名(例如span) - How to check if parent element in html is specific tagname (e.g. span) using Javascript 查询任意 html 元素,例如查看它是否被禁用,使用shinyjs - query an arbitrary html element, e.g. to see if it is disabled, with shinyjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM