Jump to content

How to handle japanese character using PHP??


ckk

Recommended Posts

Hi , I have create a form for user to search a file inside a directory. user will key-in the file name they want to search and submit, the PHP script will search the directory and list all the matched file. The problem i faced is when user key-in the japanese character, my script cannot read the character that user sent at all.

Same thing happened if inside the directory there were some files saved using japanese character, the php script totally cant display the file name corerctlly, it will only show ?????.txt. Any one know how to solved this kind of problem??
Link to comment
Share on other sites

[!--quoteo(post=384907:date=Jun 17 2006, 03:24 AM:name=kiss-o-matic)--][div class=\'quotetop\']QUOTE(kiss-o-matic @ Jun 17 2006, 03:24 AM) [snapback]384907[/snapback][/div][div class=\'quotemain\'][!--quotec--]
A code snippit would help. You also need to make sure that
1) Your web server (apahce?) supports the character set
2) Your browser is set to the right character set.

How are you trying to display the file name? Just as a normal string?
[/quote]
Hi kiss-o-matic, below is my php code
[i]
<?php

if ($handle = opendir('C:\webroot\ckk\ckk\code')) {

while (false !== ($file = readdir($handle))) {
echo "$str<br>";
}
closedir($handle);
}


?>[/i]
This php script can display the english file name correctlly but for japanese named file, it will display ????.txt
I have read some article and was told that i need to configure the mb_string function in php.ini.
I did so but still failed.
My web server is apache and for the browser, i set the character set to utf-8.

Do u have any sample that can dispaly the japanese character? and how to do if i want to compare the japanese character?
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.