We help IT Professionals succeed at work.

Convert japanese character to unicode equivalent

Renante Entera
on
Medium Priority
4,323 Views
Last Modified: 2007-12-19
Hi Experts!

I have created a function to import data from a CSV file.  In connection with this, I need to store the data in its unicode equivalent but I have no idea on how to do it.  For sample data, kindly visit this site : http://www.ex-web.biz/jp_uni.txt

Any help is greatly appreciated...


Thanks in advance!
eNTRANCE2002 :-)
Comment
Watch Question

Have a look here:
http://www.expertsrt.com/phpBB2/viewtopic.php?t=596#5662

If you download the class mentioned there and look in the example file it should be pretty self-explanatory.
Renante EnteraSenior PHP Developer

Author

Commented:
Hi nicholassolutions!

First of all, thanks for your immediately reply.  Right now, I'm creating a basic and simple code using the said class but I couldn't get it to work perfectly.  Kindly refer back to the site I provided for the code...  What's wrong with the code I've made???

I have already spend the whole day on resolving this issue but to no luck.  Huhuhu... :-((


Regards!
eNTRANCE2002 :-)
try using

$err = $converter->get_error();
print_r($err);

after you try the conversion. It seems that your input text is not in fact valid UTF-8 (I would guess you copied only part of the entire character -- it would be multiple ASCII characters, and some might not print, so you can't just cut and paste them).

Try working directly on the data from your file, without cutting/pasting anything. The code you'd need is (assuming your UTF-8 Japanese text is in $utf8):

require './class_unicode_converter_toolkit.php';
$converter = new unicode_converter_toolkit();
$converter->set_conversion_type('UTF8_TO_HTML_UCS4');
$html = $converter->convert($utf8);
echo $html;

Matt

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
>>>Try working directly on the data from your file
What I mean here is, import the data using your function, and convert it without looking at it. I have a feeling it will work when you do it directly.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.