属性中的字符将转换为unicode [英] Characters in attributes being converted to unicode

查看:102
本文介绍了属性中的字符将转换为unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用节的设置将HTML标记属性添加到Gantry 5布局中的节中.但是,任何特殊字符都会在结果HTML中呈现为Unicode十六进制字符代码.因此,添加标签

I'm adding HTML Tag Attributes to a section in a Gantry 5 layout, using the section's settings. But any special characters are rendered as Unicode Hex Character Codes in the resultant HTML. So adding the tag

data-0

到该部分

g-mainbottom1

具有属性

background-position: 50% 100px

此div的结果:

<section id="g-mainbottom1" data-0="background-position&#x3A;&#x20;50&#x25;&#x20;100px&#x3B;">

而不是期望的

<section id="g-mainbottom1" data-0="background-position: 50% 100px;">

假设我无能为力,无法阻止转换行为,那么我可以用实际文本来阻止这些字符转换为Unicode十六进制等效项吗?

Assuming there's nothing I can do to prevent the conversion behaviour, is there anything I can do with the actual text to prevenmt these characters from being converted Unicode Hex equivalents?

推荐答案

我认为您忘记了在<head>标记中使用<meta charset="UTF-8">

I think you forgot to use <meta charset="UTF-8"> in the <head> tag

<head>
    <meta charset="UTF-8">
    <meta name="description" content="Free Web tutorials">
    <meta name="keywords" content="HTML,CSS,XML,JavaScript">
    <meta name="author" content="John Doe">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

元数据是关于数据的数据(信息).

Metadata is data (information) about data.

标签提供有关HTML文档的元数据.元数据不会显示在页面上,但可以在计算机上解析.

The tag provides metadata about the HTML document. Metadata will not be displayed on the page, but will be machine parsable.

元元素通常用于指定页面描述,关键字,文档的作者,最后修改的内容和其他元数据.

Meta elements are typically used to specify page description, keywords, author of the document, last modified, and other metadata.

元数据可由浏览器(如何显示内容或重新加载页面),搜索引擎(关键字)或其他Web服务使用.

The metadata can be used by browsers (how to display content or reload page), search engines (keywords), or other web services.

HTML5引入了一种方法,使Web设计人员可以通过标签控制视口(用户在网页的可见区域)(请参见下面的设置视口"示例).

HTML5 introduced a method to let web designers take control over the viewport (the user's visible area of a web page), through the tag (See "Setting The Viewport" example below).

参考 https://www.w3schools.com/tags/tag_meta.asp

这篇关于属性中的字符将转换为unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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