简体   繁体   English

如何检测 Unicode 字符是否在我的 web 页面上正确显示?

[英]How can I detect whether Unicode characters are displayed properly on my web page?

I'm trying to use a reasonably esoteric Unicode character on a website — specifically “︙”.我正在尝试在网站上使用相当深奥的 Unicode 字符 - 特别是“︙”。 Windows XP, as far as I know, didn't ship with a font that included a glyph for this character — the Virtual PC IE 6 test image doesn't display it at any rate. Windows XP,据我所知,没有附带包含该字符字形的字体——Virtual PC IE 6 测试图像无论如何都不会显示它。

Is there any way I can detect whether the character is displaying properly, in case people are looking at the site using Windows XP without Arial Unicode MS installed?有什么方法可以检测字符是否正确显示,以防人们使用 Windows XP 而不安装 Arial Unicode MS 查看该站点?

An answer on a similar question suggested comparing the width of an element containing just this character with the width of an element containing an unprintable Unicode character. 类似问题的答案建议将仅包含此字符的元素的宽度与包含不可打印的 Unicode 字符的元素的宽度进行比较。 Unfortunately, both seem to render at the same width in browsers that display my character properly as well.不幸的是,两者似乎在浏览器中以相同的宽度呈现,也能正确显示我的角色。

Try using ⋮ ( ⋮ ), which is an alternate character for the same thing (a vertical ellipsis).尝试使用 ⋮ ( ⋮ ),它是同一事物的替代字符(垂直省略号)。 I'm not sure why there are two glyphs for this, and they are slightly different;我不确定为什么有两个字形,它们略有不同; in my own testing, ︙ ( ︙ ) uses circles for the dots, while the other one uses squares.在我自己的测试中,︙ ( ︙ ) 使用圆圈作为点,而另一个使用正方形。 That probably varies by font though.不过,这可能因字体而异。 And anyway, you have to increase the font size to ridiculous sizes to notice a difference.无论如何,您必须将字体大小增加到荒谬的大小才能注意到差异。

What you are trying to do is virtually impossible, at least not in a safe way .你试图做的事情几乎是不可能的,至少不是以一种安全的方式

Instead you should clearly define your supported audience, specifying exactly what browsers you will support and for unsupported ones display an warning.相反,您应该清楚地定义您支持的受众,准确指定您将支持哪些浏览器,并且对于不支持的浏览器显示警告。

BTW, Do not display the warning for any browser that it was not identified by you, just for the that were identified as bad.顺便说一句,不要为任何未被您识别的浏览器显示警告,仅针对被识别为坏的浏览器。

You could add an embedded font but this will work only on some browsers and probably not on mobile devices.您可以添加嵌入式字体,但这仅适用于某些浏览器,可能不适用于移动设备。 I wouldn't recommend you to use such esoteric characters.我不建议您使用这种esoteric字符。

One idea http://www.devslide.com/labs/browser-detection一个想法http://www.devslide.com/labs/browser-detection

NOTE : in the text above, I refer to a browser as a combination of browser and operating system.注意:在上面的文字中,我将浏览器称为浏览器和操作系统的组合。 Today most browsers do properly display Unicode characters, BUT the fonts do not, and the user will see boxes instead of correct characters.今天大多数浏览器都能正确显示 Unicode 字符,但 fonts 不能,用户将看到框而不是正确的字符。 A well designed web page must render properly with the default fonts existing on the client computer.设计良好的 web 页面必须使用客户端计算机上现有的默认 fonts 正确呈现。

Use an embeded font.使用嵌入字体。 You have to have 4 versions or so of the font file around for it to work in all browsers, but it works in IE6 Up and all modern browsers, including iOS mobile devices..您必须有 4 个左右的字体文件版本才能在所有浏览器中运行,但它适用于 IE6 Up 和所有现代浏览器,包括 iOS 移动设备。

http://www.fontsquirrel.com/fontface/generator http://www.fontsquirrel.com/fontface/generator

You can upload a TTF font and get the whole package back as a download - all the font files needed and the CSS plus a sample page to test with.您可以上传 TTF 字体并下载整个 package - 所有需要的字体文件和 CSS 以及用于测试的示例页面。 I have not found a browser that this will not work in (including 1-2 version back from current, depending on the browser).我还没有找到不能在其中工作的浏览器(包括从当前版本返回的 1-2 版本,具体取决于浏览器)。

I am not sure you need to worry about this... according to the Microsoft site, Arial Unicode MS is automatically installed for Windows XP.我不确定你是否需要担心这个......根据微软网站,Arial Unicode MS 会自动安装到 Windows XP。

http://office.microsoft.com/en-us/visio-help/install-the-universal-font-for-unicode-HP005255840.aspx http://office.microsoft.com/en-us/visio-help/install-the-universal-font-for-unicode-HP005255840.aspx

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

相关问题 如何检测谷歌网络字体何时准备好并显示在页面中? - How can I detect when a google web font is ready and displayed in the page? Javascript:如何将unicode值转换回字符? - Javascript: How can I convert my unicode values back to characters? 如何使用JavaScript将Unicode转换为显示在网页中的字符? - How to convert Unicode to character which is displayed in web page using JavaScript? 如何使用JavaScript或JQuery检测URL是否指向网页或二进制文件? - How do I detect with JavaScript or JQuery whether a URL points to a web page or a binary file? 如何判断“我的页面上是否存在 Javascript object”? - How can I tell 'Whether a Javascript object exists on my page'? 如何检测 iframe 是否已加载? - How can I detect whether an iframe is loaded? 如何使用javascript检测网页是否在移动设备上响应 - how to use javascript to detect whether a web page is responsive on mobile 如何检测是否加载了Web字体并隐藏文本节点直到发生这种情况? - How can I detect whether a web font is loaded and hide text nodes until that happens? 如何检测移动浏览器或应用程序是否打开了网页? - How can I detect if a web page is opened by a mobile browser or an app? 如何检测我的音频流是:播放,暂停还是已完成? - How can I detect whether my audio stream is: playing, paused or finished?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM