Chinese characters showing as question marks

非 Y 不嫁゛ 提交于 2019-12-01 12:10:41

问题


This has been asked before, but I can't figure out what's wrong. I'm printing pdfs using phantomjs .render().

The rendered page is basically a local static site with these properties:

  • <meta charset="UTF-8">
  • font: normal 17px helvetica,arial,verdana,sans-serif
  • running and tested on Windows locally and Azure Worker Roles
  • Chinese language pack installed and working when printing the same page from Chrome (Installed fonts e.g. Arial Unicode MS, SimSun ...)

Latin characters are all fine, just Chinese ones are displayed as "?"

For example

I also tried the entire page in Arial or SimSun only, but no difference.

Any idea how to get this working on Windows?

Thanks!


回答1:


You need a chinese font. None of them is in a chinese font family.

font: normal 17px helvetica,arial,verdana,sans-serif

Here are some font has chinese char.

宋体:SimSun; 黑体:SimHei; 新宋体:NSimSun; 微软雅黑:Microsoft YaHei; 新細明體:PMingLiU

This is much more than a guide.Chinese Standard Web Fonts: A Guide to CSS Font Family Declarations for Web Design in Simplified Chinese

This has Traditional Chinese fonts.Chinese web fonts

Google's font. Sorry for not being a link, there is a limit for me.

noto-sans-hans

Adobe's typekit

source-han-sans

Test Html file:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>你好中文!</title>
    <style type="text/css">
        p.serif{font-family:"Times New Roman",Georgia,Serif}
        p.sansserif{font-family:SimSun}
        p.s1{font-family: 黑体}
        p.s2{font-family: KaiTi}
        p.s3{font-family: Microsoft YaHei}
    </style>
</head>

<body>
    <div>
    <p class="serif">你好中文!111</p>
    <p class="sansserif">宋体</p>
    </div>
    <div>
        <p class="s1">黑体</p>
        <p class="s2">楷体</p>
        <p class="s3">微软雅黑</p>
    </div>
</body>
</html>

Result

Lastest to do, try to change your location to china. I don't expect this working, as I tried the phantomjs in win10 ENG preview, working very well. Control Panel > Region > Administrative > Language for non-Unicode programs



来源:https://stackoverflow.com/questions/29458106/chinese-characters-showing-as-question-marks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!