jshpik1 Posted February 3, 2008 Share Posted February 3, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/ Share on other sites More sharing options...
haku Posted February 3, 2008 Share Posted February 3, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/#findComment-456721 Share on other sites More sharing options...
jshpik1 Posted February 3, 2008 Author Share Posted February 3, 2008 I also have a meta tag, not sure what it's for: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> It's showing no value under default charset for the phpinfo. Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/#findComment-456742 Share on other sites More sharing options...
jshpik1 Posted February 3, 2008 Author Share Posted February 3, 2008 Those characters aren't from hardcoded or mysql, no clude where they came from. I tried removing the tag and it didn't change anything. Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/#findComment-456770 Share on other sites More sharing options...
haku Posted February 3, 2008 Share Posted February 3, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/#findComment-456771 Share on other sites More sharing options...
jshpik1 Posted February 3, 2008 Author Share Posted February 3, 2008 They're from the php document. Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/#findComment-456778 Share on other sites More sharing options...
haku Posted February 3, 2008 Share Posted February 3, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/#findComment-456783 Share on other sites More sharing options...
jshpik1 Posted February 3, 2008 Author Share Posted February 3, 2008 There is nothing that states accept-charset, it has default charset which states "no value" Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/#findComment-456805 Share on other sites More sharing options...
haku Posted February 3, 2008 Share Posted February 3, 2008 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"> Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/#findComment-456810 Share on other sites More sharing options...
jshpik1 Posted February 3, 2008 Author Share Posted February 3, 2008 Hahahaha, all I did was change the meta tag to what you said and it fixed it. I don't think I have access to php.ini although my host may give it if I asked. Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/#findComment-456842 Share on other sites More sharing options...
haku Posted February 3, 2008 Share Posted February 3, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/89195-php-include-file-unicode-problem/#findComment-456846 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.