在HTML上标题UTF-8 [英] Title UTF-8 on HTML

查看:215
本文介绍了在HTML上标题UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面标题上出现UTF-8字符问题,
我想在页面的标题上添加这个字符 - >♫<---(音乐符号)

I'm having a problem with UTF-8 character on the page title, I want to add this on the title of the page --> ♫ <--- (the Music symbol)

事情是,有时它可以工作(在Google Chrome上),有时它不会(当它不起作用时,它似乎是一个应该是错误的平方的编码)奇怪。
在firefox中,当您查看窗口顶部的标题(页面中出现的标题)时,它总是可以工作,但是下面的栏中出现的标题再次出现在方块中。 :/
我该如何解决这个问题?

The thing is, sometimes it works (on Google Chrome) and sometimes it doesn't (when it doesn't work, it appears a square that is supposed to be an error of encoding) weirdly. And in firefox, it always work when you look to the title in the top of the window (the title that appears up in your page) but the title that appears in the bar below appears the square thing again. :/ What do I do to fix this?

我正在使用Javascript来定义标题,这个js文件正在使用PHP定义它utf-8。

I'm defining the title via Javascript by a js file which I'm using PHP to define it utf-8 as well.

var title =♫我的音乐;
document.title = title;

var title = "♫ My Music"; document.title = title;

顺便说一下,它似乎总是在Linux上工作,但在Windows上,它会做那些东西。 = /

by the way, it seems to work always on Linux, but on Windows, it does those stuff. =/

提前感谢

推荐答案

这是一个字体问题而不是编码问题;代替字符的小矩形通常意味着字符不在所使用的字体中。

This is a font problem rather than an encoding problem; a small rectangle in place of a character typically means that the character is not present in the font(s) used.

浏览器通常在渲染 title 元素内容(页面外部的某处)。这些字体可能取决于操作系统中的设置。例如,在Windows 7上,它们的默认值为9pt Segoe UI,一种较为丰富的字体,而较旧的系统则具有较为有限的字体。无论如何,这不在作者的手中。

Browsers typically use some specific fonts when they render title element contents (somewhere outside the page itself). These fonts may depend on the settings in the operating systems. On Windows 7 for example, the default for them is 9pt Segoe UI, a relatively rich font, whereas older systems have more limited fonts. Anyway, that’s outside an author’s hands.

所以结论是在 title 元素中应避免使用特殊符号。它们的渲染是不能保证的,而且对于搜索引擎而言,它们可能没有价值。

So the conclusion is that special symbols should be avoided in title elements. Their rendering is not guaranteed, and they probably have no value as far as search engines are considered.

这篇关于在HTML上标题UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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