Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Error message in script with Japanese characters

by martymart (Deacon)
on Jan 17, 2003 at 14:15 UTC ( [id://227683]=perlquestion: print w/replies, xml ) Need Help??

martymart has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,
I wrote a simple script that runs on ini files with localisable content, to check for errors, etc.
All it does for example is replaces:
the letter a with ä the letter o with ô
The script works fine for Latin characters, dutifully making its replacements where an a or an o was found.No problems there, so being brave I thought to myself, what the hell, I'll give it a go with Japanese and see what happens....not much
What did happen was that I kept on getting the error message
Use of uninitialized value in substitution iterator at line 52 Use of uninitialized value in substitution iterator at line 52
I'm fairly new to perl, and was wondering why this was occurring, as well as a possible workaround. And also is there any information out there on Japanese language support for perl newbie? I see in CPAN that there's a module called Unicode::Japanese, could this be used?
Thanks in advance,
Martymart

Replies are listed 'Best First'.
Re: Error message in script with Japanese characters
by John M. Dlugosz (Monsignor) on Jan 17, 2003 at 17:14 UTC
    I don't know what your line 52 may be, but here is a problem you may have:

    In the Japanese .ini file, the codes for those letters may be different. What "code page" (encoding system) is the file using? It may be using two-byte sequences for some characters, one byte for others, and different from the accented letters in the Latin-1 code page.

    The best thing to do is transcode the INI file from whatever it's written in to Perl's native UTF-8 encoded Unicode. Then with use utf8; in effect, your tr or s/// will work just fine. Then, transcode the result to the desired character set.

    That stuff is built into Perl 5.8 ! If you aren't using it yet, this might be a compelling reason.

    —John

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://227683]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-23 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found