简体   繁体   English

本地主机不支持日语字符

[英]japanese character is not supported in localhost

I have a project which has japanese characters in it.我有一个项目,里面有日文字符。 When I run the project which is already on the server (the live version) japanese characters are displayed.当我运行已经在服务器上的项目(实时版本)时,会显示日语字符。 However, the same files with no changes in the code, if I run on localhost then japanese characters are displaying something like this "レストラン".但是,代码中没有更改的相同文件,如果我在本地主机上运行,​​那么日语字符会显示类似“レストラン”的内容。 all files includes .所有文件包括 . and i'm using google chrome.我正在使用谷歌浏览器。 what should I do to make it support japanese characters?我该怎么做才能让它支持日文字符? any help would be appreciated.任何帮助,将不胜感激。

Add following:添加以下内容:

<meta charset="Shift-JIS"/>

to your file if you use HTML5, or如果您使用 HTML5,则添加到您的文件,或

<meta http-equiv="Content-Type" content="text/html; charset=Shift-JIS" />

if you use HTML 4.01.如果您使用 HTML 4.01。

The reason why it works over the webserver is because it transmits HTTP headers with correct encoding.它在网络服务器上工作的原因是因为它以正确的编码传输 HTTP 标头。 On your local copy of .html , there are no such headers, so the browser checks the <meta/> tags (which are missing), and if it fails to find these, it guesses encoding, which in this case is UTF8..html的本地副本上,没有这样的标头,因此浏览器会检查<meta/>标记(缺少),如果找不到这些标记,它会猜测编码,在这种情况下是 UTF8。 (If you use webserver in localhost too, it might be misconfigured. In any case, it's a good practice to always include charset information.) (如果您也在 localhost 中使用 webserver,它可能配置错误。无论如何,始终包含字符集信息是一个好习惯。)

@AshishAcharya I'm pretty sure OP uses Shift-JIS rather than UTF8. @AshishAcharya 我很确定 OP 使用 Shift-JIS 而不是 UTF8。 The page is rendered as UTF8 though.该页面虽然呈现为 UTF8。

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

相关问题 图像路径中的日语字符 - Japanese Character in Image Path 在html标签中显示日语,孟加拉语字符 - Showing japanese, Bengali character in html label 日语Unicode字符使CSS浮动向左反转 - Japanese unicode character is reversing CSS float left 我需要帮助在html页面中显示日语字符 - I need help to display japanese character in a html page 如何使日文字体(Ipaex gothic / mincho)加粗? - How to make japanese character font (Ipaex gothic / mincho) bold? 我如何使用包含日文字符的文件路径作为 href - How could I use file path containing Japanese character for href 在 MS Excel 中打开时,日文字符在使用 apache commons csv 生成的 csv 文件中显示为乱码 - When opened in MS Excel Japanese character shows as garbled character in csv file generated using apache commons csv IE 8浏览器不支持新行字符“\\ n” - New line character “\n” not supported in IE 8 browser 为了支持中文/日语字符,HTML文档中的字符集声明应该是什么? - To support Chinese/Japanese characters what should be the character set declaration in HTML document? 使用带有 YaHP Html 到 Pdf 转换器的 Java 将带有日语字符的 HTML 转换为 PDF 的问题 - Problem converting HTML with Japanese character To PDF using java with YaHP Html to Pdf Converter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM