Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Japanese characters problem

Posted on 2007-03-26
2
Medium Priority
?
272 Views
Last Modified: 2011-09-20
I am about to develope a website in Japanese using PHP and mySQL but I have problem displaying Japanese character correctly. The data is retrieved from the database. My site is encoded in JIS-Shift

The question is: which character set should I use to store my data?

Thank you
0
Comment
Question by:khoama
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Expert Comment

by:ajd777
ID: 18797878
Your best bet would be UTF-8. for both the site and the database, but no matter what you choose they should be the same. Otherwise it is like trying to translate a German book with a French dictionary.
0
 

Accepted Solution

by:
ajd777 earned 375 total points
ID: 18797883
Actually your "real" best bet would to just encode everything as HTML entities when you store it in the database. This will ensure it displays properly no matter what encoding the page uses.

To convert characters to entities you cold use a Javascript like:

function convertfromchars(someelementid){
      var content = document.getElementById(someelementid).value;
      var result = '';
      for (i=0; i<content.length; i++)
    {
        charCode = content.charCodeAt(i);
        if (charCode <= 127)
            result += content.charAt(i);
        else
            result += '&#' + charCode + ';';
    }
      document.getElementById(someelementid).value = result;
}

or you could do it in PHP by using a function like:

function fix_chars($content,$encoding=''){
 if(!$encoding){$encoding = "AUTO";}
             $content=mb_convert_encoding($content,"HTML-ENTITIES",$encoding);
       return $content;
 }
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
In this article, we’ll look at how to deploy ProxySQL.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question