I've been fighting with ways to embed Japanese text into my perl asp/cgi pages. For those of you in a similar situation the short answer is, "It can't be done." So I came up with this rediculous hack which happens to do the particular job I need done in this instance.
<%@ Language = PerlScript %>
<html><head>
<title> Japanese Perl Integration Trick #1 </title>
</head>
<body>
<h2>Lexicon's Loan Book</h2>
Those of you visiting this page almost assuredly owe me
money. You remember all those yen I lent you while you
were in town? Time to pay up!<p>
Obligatory Japanese<p>
これは日本語です。意味ではありません。日本語だけです。
<%
# People who owe me cash (or, sample hash)
my %loans = {
'Vroom' => 5000,
'PsychoSpunk' => 10000,
'Azatoth' => 10000000,
}
# Some basic basic html templating
my $table_start = "<tr><td width='50%' bgcolor='red'>";
my $table_mid = "</td><td width='50%' bgcolor='blue'>";
my $table_end = "</td></tr>";
# HERE IT IS! THE SECRET!
# Wherever you call this subroutine, the yen mark will appear.
# Remember that it pops up instantly, it doesn't return the string.
sub yen { %> 円 <% } # The Japanese character for yen.
%> <table> <%
# Here we go, actual use:
for (keys %loans) {
$Response->write( $table_start
. $_
. $table_mid
. %loans{$_}
. ¥
. $table_end
);
}
%>
</table></body></html>
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.