简体   繁体   English

html特殊字符UTF-8

[英]html special character UTF-8

i want to design my own video player. 我想设计自己的视频播放器。 I want to add this special character as a "volume"-button: 🔉 http://www.fileformat.info/info/unicode/char/1f509/index.htm . 我想这个特殊字符添加为“音量”按钮上:🔉 http://www.fileformat.info/info/unicode/char/1f509/index.htm But it always shows a weird rectangle with the number 01F509. 但是它总是显示一个怪异的矩形,编号为01F509。

Whats wrong ? 怎么了 ?

greetings 问候

To avoid encoding issues, try including the character in your HTML code using the hexadecimal entity notation: &#x1F509 ; 为避免编码问题,请尝试使用十六进制实体表示法将字符包含在HTML代码中: &#x1F509 ; then make sure that the font you are using contains this character, else you'll see a rectangle in place of the character. 然后确保您使用的字体包含此字符,否则您会看到一个矩形代替该字符。

You may create your own font with the desired character using tools such as http://icomoon.io 您可以使用诸如http://icomoon.io之类的工具用所需的字符创建自己的字体。

Also note that some browsers have issues displaying characters outside of the range 0000 to FFFF ( plane 0 of the Basic Multilingual Plane (BMP) ). 还要注意,某些浏览器在显示字符时会遇到问题,这些字符的显示范围在0000到FFFF( 基本多语言平面(BMP)的平面0 )之外。 I have experienced the issue with Safari on Windows and IE <= 8. So try avoiding this range if you want to support all browsers. 我在Windows和IE <= 8上遇到了Safari的问题。因此,如果要支持所有浏览器,请尽量避免使用此范围。

When you see a weird rectangle with the number 01F509, it means that the browser has correctly recognized the character but cannot display it due to lack of glyph for it. 当您看到带有数字01F509的怪异矩形时,表示浏览器已正确识别该字符,但由于缺少字形而无法显示该字符 Either the system has no font containing a glyph for the character, or the character is unable to use such a font, due to a browser bug. 系统没有包含该字符的字形的字体,或者由于浏览器错误,该字符无法使用此类字体。 For generalities, see my Guide to using special characters in HTML . 有关一般性,请参阅《 HTML中使用特殊字符的指南》

The Fileformat.info page cited has a link to a list of fonts that support the character . 引用的Fileformat.info页面具有指向支持该字符字体的列表的链接。 The list is short: Quivira, Segoe UI Emoji, Segoe UI Symbol, Symbola. 列表很短:Quivira,Segoe UI Emoji,Segoe UI Symbol,Symbol。 (LastResort is not a real font.) (LastResort不是真正的字体。)

Segoe UI fonts are proprietary and available only in relatively new versions of Windows. Segoe UI字体是专有的,仅在相对较新的Windows版本中可用。 Besides, there fonts exist in several version, and this character seems to be a rather recent addition. 此外,字体有多种版本,并且该字符似乎是最近才添加的。

This means that you wold need to use Quivira or Symbola as a web font (downloadable font). 这意味着您需要将Quivira或Symbola用作网络字体(可下载的字体)。 If you choose to do that, use eg http://www.fontsquirrel.com/ to generate the font files and the CSS code for using them. 如果选择这样做,请使用例如http://www.fontsquirrel.com/生成字体文件和CSS代码以供使用。 Note that both Quivira and Symbola rather large fonts, so using them just to get one glyph is a bit disproportionate. 请注意,Quivira和Symbola都使用较大的字体,因此仅使用它们来获得一个字形就有点不成比例。

At this point, it is rather obvious that some other approach is most probably better, eg using an image in sufficient size and reducing it according to font size by setting its height in em units. 在这一点上,很明显,其他方法可能更好,例如使用足够大小的图像,并通过以em单位设置其高度,根据字体大小将其缩小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM