最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Using German characters (e.g. Umlaut) in HTML - Stack Overflow

programmeradmin5浏览0评论

I am trying to encode German characters in html. I just want to use the special character codes. For the Umlaut, I've tried using both Ü 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. I am using Javascript to write a German word on the page. 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!

 var strings = {
          'About': {
            'de': 'Über'
          },

I am trying to encode German characters in html. I just want to use the special character codes. For the Umlaut, I've tried using both Ü 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. I am using Javascript to write a German word on the page. 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!

 var strings = {
          'About': {
            'de': 'Über'
          },
Share Improve this question edited Oct 4, 2015 at 22:37 Michael Benjamin 373k110 gold badges613 silver badges730 bronze badges asked Sep 27, 2015 at 19:39 KerenKeren 2171 gold badge9 silver badges20 bronze badges 1
  • Can you show what you are seeing that seems improper? What browser are you using? – chicks Commented Sep 27, 2015 at 21:16
Add a ment  | 

2 Answers 2

Reset to default 5

Try using Ü for the German character Ü.

You need to escape special characters in HTML, unless...

You address the encoding issue on a document-wide level by adding the following line of code at the beginning of the <head> section:

<meta charset="utf-8">

Then you don't need to escape special characters individually.


Further reading:

  • Character encodings for beginners
  • Declaring character encodings in HTML
  • Declaring character encodings in CSS

UPDATE 1 (Javascript)

  • Convert special characters to HTML in Javascript
  • How to convert characters to HTML entities using plain JavaScript

UPDATE 2 (Squarespace)

  • HTML Special Characters and Squarespace
  • special character in squarespace (text block)
  • If you are a Squarespace customer, they provide 24/7 customer support. Contact them directly.

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

发布评论

评论列表(0)

  1. 暂无评论