Jump to content

PHP Include File, Unicode Problem


jshpik1

Recommended Posts

Hello,

 

I have a PHP file that has some unicode characters (japanese), for text.  I use Notepad to do all my work in.  I save the file in UTF-8 format rather than ANSI, the .tpl file works correctly, however the .php shows up strange and with additional characters (looks like some of the PHP code).  Help is greatly appreciated.

Link to comment
Share on other sites

Is the text that is coming out unreadable dynamic text from a database, or text that has been hardcoded into the document?

 

create a new php file, and add this one line of code to it:

 

<?php echo phpinfo(); ?>

 

Then upload that to the folder that you are having troubles with, and open that file through your browser. Then tell me what it says under

 

HTTP Headers Information  =>  Accept-Charset

Link to comment
Share on other sites

You have some Japanese words that are not displaying correctly right? They should be reading as 漢字 but are looking like something else. You either made a query to your database and echoed these characters (words), or they are part of your php document. Which one is it?

Link to comment
Share on other sites

Ok, now create a new php file, and add this one line of code to it:

 

Code:

 

<?php echo phpinfo(); ?>

 

 

Then upload that to the folder that you are having troubles with, and open that file through your browser. Then tell me what it says under

 

HTTP Headers Information  =>  Accept-Charset

Link to comment
Share on other sites

Alright, then your problem is that your default character set is not set to utf-8 in your php.ini file. You need to do two things.

 

First you need to open up your php.ini file, and look for the line that looks something like this:

 

default_charset = _____________

 

it should read:

 

default_charset = "UTF-8"

 

Save that, and re-upload php.ini to the same place it was on your server.

 

Next, you need to change this line in your code:

 

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

 

And make it read like this:

 

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

Link to comment
Share on other sites

Good deal then.

 

If you are planning on making a Japanese site, I wouldn't recommend utf-8 for your encoding. Making dynamic Japanese sites is quite difficult, and requires different encodings in different areas. But utf-8 has some major issues so you don't want to use it. But if you are just planning on making a site that will display some Japanese characters, utf-8 will suit your needs fine.

 

Good luck!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.