PDA

View Full Version : Japanese Character with mySQL



Tomo
08-23-2004, 01:24 PM
Is someone know Hosting Co. which can use Japanese Character with mySQL?(Compiled with Japanese)

I can use mySQL without Japanese compiled but search functions does not work correctly...

Ghurqril
03-16-2020, 05:05 AM
Are you using utf8 encoding? In order for your search to work properly, you need to:

1. Use utf8 encoding when creating a database
2. Make sure all text fields (varchar and text) are using UTF-8
3. When you make a connection do this before you query/update the database:
SET NAMES utf8;
4. With phpMyAdmin - Choose UTF-8 when you login
5. Set web page encoding to utf-8 to make sure all post/get data will be in UTF-8, PHP code (first line in the php file or at least before any output):
header('Content-Type: text/html; charset=UTF-8');
6. Make sure all your queries are written in UTF8 encoding. If using PHP:
6.1. If PHP supports code in UTF-8 - just write your files in UTF-8.
6.2. If php is compiled without UTF-8 support - convert your strings to UTF-8 like this:
$str = mb_convert_encoding($str, 'UTF-8', '<put your file encoding here');
$query = 'SELECT * FROM test WHERE name = "' . $str . '"';

This is a great guide from a stackoverflow post, you should check it out here (https://stackoverflow.com/questions/5360544/select-mysql-rows-with-japanese-characters) and look at other answers if this one doesnt help you.