Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Kanji character-set conversions (EUC to SJIS, etc.) w/jcode.pl...

Status
Not open for further replies.

mlg4035

Technical User
Aug 18, 2002
27
JP
Can anyone help me understand how to use jcode.pl :

ftp://ftp.iij.ad.jp/pub/IIJ/dist/utashiro/perl/

to handle Japanese Kanji encoding conversions in my CGI/Perl programs [particularly EUC to SJIS, and SJIS to EUC]?

I understand the basics (use SJIS for display, EUC for the CGI program to work with, and JIS for email delivery), and I know the syntax for what I want to do [i.e.

&jcode::convert( *File, "sjis", "euc")

to convert 'File' to SJIS from EUC encoding]. However, it doesn't work reliably for me all the time. Sometimes it works sometimes not.

For example, I can save HTML form-input to a CSV file and everything looks fine, but when I read that data back out to the HTML form for editing, some of the characters do not display correctly[although the data in the CSV file hasn't changed].

I'm going to go through the documentation step by step and perform some basic testing of the examples. But,in the meantime, if anyone knows more details or 'tricks' about using this Perl library, please post a reply. Thanks!
 
Well, thanks anyway folks. After some extensive testing I figured out what my problem was: the HTML template file I was working on had a mixture of SJIS and EUC-encoding! (It displayed some characters correctly because I set my browser to SJIS encoding.)

All I had to do was convert my entire template file to Shift-JIS (SJIS) using a great shareware program called "Quick Kanji Code Converter" version 3.1 developed by Kimihiki Sato to do that on the desktop. (This is a GREAT utility that you can use to easily convert files from one encoding to another.)

No worries, you just start off by converting SJIS to EUC before passing the data to the CGI program, and then convert the data returned by the program from EUC back to SJIS before sending/printing it to the (SJIS-encoded)template for display. Not too mysterious...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top