简体   繁体   中英

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

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

if you use HTML 4.01.

The reason why it works over the webserver is because it transmits HTTP headers with correct encoding. 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. (If you use webserver in localhost too, it might be misconfigured. In any case, it's a good practice to always include charset information.)

@AshishAcharya I'm pretty sure OP uses Shift-JIS rather than UTF8. The page is rendered as UTF8 though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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