Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

PerlScript and Localization

by Lexicon (Chaplain)
on May 10, 2001 at 14:54 UTC ( [id://79356]=perlquestion: print w/replies, xml ) Need Help??

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

I am trying desperatly to enable reliable Japanese support into my Perlscript. Do any of you have experience with getting perl to play nicely with a 2-Byte character set under PerlScript in IIS? Currently, IIS does nothing short of completely freak out. Consider this code:

<%@ LANGUAGE = PerlScript %> <html><body> <% use locale; $Response->Write("English<p>"); # English $Response->Write("日本語<p>" ); # Japanese (In Japanese) %> </body></html>

Most of you will see what Perl probably see...a bunch of line noise. I can leave the code alone, hit refresh, and Perl/IIS will generate different error values on different reloads. Usually it's a simple Syntax Error or </code>Cannot find string terminator '"'</code> but sometimes it will:

PerlScript Error Error:'80004005' (in cleanup) Unrecognized character \xBC example.asp, at Line 6

and sometimes, just for spite, it will work. ;-)

Perl and IIS are fine. If I take out the Japanese, I've no problems. Actually, if I put the Japanese inside of <%= 日本語 %> it seems to work fine, but that is kind of limiting when I need to send e-mail. I've tried embedding the Japanese in HEREDOC, qq() and others. No luck. I'm tempted to try to start parsing it out of a file, but one can imagine how ugly that might become.

Thus I ask: I know PerlScript doesn't really support Japanese yet, but is there any reliable way I can force it to do so anyway?

NT Server 4.0 Service Pack 6 & IIS
ActiveState 5.6.0 Build 623 (5.6.1 636 is out. I might try that tomorrow)

-Lexicon

Replies are listed 'Best First'.
Re: PerlScript and Localization
by Lexicon (Chaplain) on May 11, 2001 at 10:49 UTC
    Well, it wasn't what I was looking for, but this is the best solution I could find:
    sub UserError { my $msg = shift; my $serialcode = shift; my $email = shift; open JAPANERROR, $japanerrorfile or die "Can not open $japanerrorfile: $!"; my @JapanArray = <JAPANERROR>; close JAPANERROR or die "Can not close $japanerrorfile: $!"; chomp @JapanArray; my ($j_invalidcode, $j_badcodelength, $j_invalidemail, $j_expiredtrial, $j_unknownerror) = @JapanArray; $Response->Write("<html><body><h3>"); if ( $msg =~ /Bad code length/ ) { $Response->Write( "$j_badcodelength ($serialcode)" ) } elsif ( $msg =~ /Not a valid code/ ) { $Response->Write( "$j_invalidcode ($serialcode)" ) } elsif ( $msg =~ /Not a valid Email/ ) { $Response->Write( "$j_invalidemail ($email)" ) } elsif ( $msg =~ /You already used your 3 trial time/ ) { $Response->Write( "$j_expiredtrial ($email)" ) } else { $Response->Write( "$j_unknownerror" ) } $Response->Write("</h3></body></html>"); exit(1); }
    And here's an example of the error file, not yet translated:
    ERROR : Bad code length ERROR : Not a valid code ERROR : Not a valid Email ERROR : You already used your 3 trial time ERROR : Unknown Error

    -Lexicon

Re: PerlScript and Localization
by AidanLee (Chaplain) on May 10, 2001 at 18:52 UTC
    I'm not sure how pragmas work in perlscript as opposed to normal perl, but perhaps a use utf8 would clue the perl interpereter into what you are trying to do?

    Update Not that I think you're looking to go this far out of your way, but starting on page 276 of "Unicode: A Primer" by Tony Graham outlines unicode use in Perl (as of 5.005). I imagine the examples hold equally as well for Perl 5.6

Re: PerlScript and Localization
by AgentM (Curate) on May 10, 2001 at 17:27 UTC
    You might give quotemeta a try. Given all of the other stuff you've tried, it most likely will end up pumping out garbage, but it's at least worth a shot.
    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-25 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found