473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

iconv

I need to convert Japanese characters to UTF-8. I tried using this
command on a PHP 5.0.3 server:
$out = iconv("iso-2022-jp", "utf-8", $in);
But it does not work. Can anyone tell me what I'm doing wrong?

(Note: I also tried this, unsuccessfully, with Chinese characters:
$out = iconv("gb2312", "utf-8", $in);
)

Jul 17 '05 #1
3 5059
pb*******@hotmail.com wrote:
I need to convert Japanese characters to UTF-8. I tried using this
command on a PHP 5.0.3 server:
$out = iconv("iso-2022-jp", "utf-8", $in);
But it does not work. Can anyone tell me what I'm doing wrong?


You might start by mentioning what happens. Do you get an error message?
An empty string? A garbled string? FALSE?

Can you confirm that the iconv module is built-in or loaded? Can you
confirm that the input really is iso-2022-jp, and not some other
encoding such as Shift-JIS? Can you confirm that the input is valid?

-- brion vibber (brion @ pobox.com)
Jul 17 '05 #2
That's why I added the note about gb2312 - I'm SURE my input is in
simplified Chinese, but I get NULL output with the PHP command $out =
iconv("gb2312", "utf-8", $in);

My PHP 4 ISP activated ICONV, and I tried this also on a PHP 5.0.3
server. When you say 'confirm that the iconv module is built-in or
loaded,' are you suggesting that something else might need to be done?

Thanks.

Jul 17 '05 #3
pb*******@hotmail.com wrote:
That's why I added the note about gb2312 - I'm SURE my input is in
simplified Chinese, but I get NULL output with the PHP command $out =
iconv("gb2312", "utf-8", $in);
You haven't provided any sample data or a test program or described the
system it's running on (OS, version, etc), so it's hard to reproduce. :)

Try this program:

<?php
$in =
urldecode('%CE%AC%BB%F9%B0%D9%BF%C6%A3%AC%D7%D4%D3 %C9%B5%C4%B0%D9%BF%C6%C8%AB%CA%E9');
$out = iconv("gb2312", "utf-8", $in);
echo urlencode($out);
?>

The output should be:

%E7%BB%B4%E5%9F%BA%E7%99%BE%E7%A7%91%EF%BC%8C%E8%8 7%AA%E7%94%B1%E7%9A%84%E7%99%BE%E7%A7%91%E5%85%A8% E4%B9%A6

I tested this successfully on PHP 4.3.10 on a Red Hat Linux 9 system.
My PHP 4 ISP activated ICONV, and I tried this also on a PHP 5.0.3
server. When you say 'confirm that the iconv module is built-in or
loaded,' are you suggesting that something else might need to be done?


Check for instance phpinfo() output to make sure iconv is listed
properly. (If it weren't you should get a fatal error as the iconv
function won't be defined, but...)

It's also possible there's something wrong with the iconv library on
your system; see http://www.php.net/iconv
"Supported character sets depend on the iconv implementation of your
system. Note that the iconv function on some systems may not work as
you expect. In such case, it'd be a good idea to install the GNU
libiconv library. It will most likely end up with more consistent results."

Does it fail in the same way on both systems? What OS are they running?
Are only Asian encodings affected, or all encodings? Can you do an iconv
from iso-8859-1 to utf-8, for instance?

You might also try mb_convert_encoding if the mbstring module is enabled.

-- brion vibber (brion @ pobox.com)
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Erik Neves | last post by:
I need help with utf-8 before i go bald and the rest of my hair turns white! Platform: Mac OS X 10.2.6 Safari 1.0 (v85) Internet Explorer:mac 5.2.3 (5815.1) Apache 2.0.47 PHP 4.3.2 (Apache 2...
1
by: Al | last post by:
Hi Folks, I am trying to run a script which is installed on a web server that I do not own or administer. The script relates to a emailing list. When I go to send an email I get the...
1
by: yong | last post by:
I want to use iconv.h to convert some text to another charset. The code is below: ====== #include <stdio.h> #include <stdlib.h> #include <iconv.h> int main()
3
by: s_emiliano | last post by:
I am trying to get " feed to javascript" (http://jade.mcli.dist.maricopa.edu/feed/index.php) to run on my windows 2003 server. The testing script that they they provide gives this error when run:...
4
by: B.r.K.o.N.j.A | last post by:
Does anyone has any experience with these two, I've lost a s**tload of time trying to make them work with a well formed xml document encoded in windows-1250 encoding, but simplexml works only with...
2
by: kkadrese | last post by:
hello group, I cannot figure out how to use iconv to "normalize" characters specific to some language. I need it in file upload where I take a file from local disc and then save to server and...
5
by: kp | last post by:
Hi, I am compiling on an AIX 5.1 box and my test machine is AIX 5.3. I run the foll. steps for compiling my test binary "test" /usr/vacpp/bin/xlC test.c -c -o test.o -I/home/jag/progs/include...
1
hadi00
by: hadi00 | last post by:
Hey there, first of all I don't know if this is the best forum to best my question in , if it's not, am sorry a lot. Secondly; I want anyone uses Iconv System tool on "win xp sp2 os",plz to help me...
5
by: jimmyg123 | last post by:
Hey everyone, Sorry for a question on an outdated PHP, but I am trying to get iconv working on php4.3.3. When I enable it in php.ini by removing the ; from the ;extension=php_iconv.dll line, php...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.