in reply to Handling Traditional Chinese Characters
Here are some tips on ways to deal with everything in UTF8:
use Encode; use Encode qw(encode decode); binmode STDOUT, ':utf8'; print "Content-type: text/html; charset=utf-8\n\n"; open SOURCE, '<:encoding(utf8)',$sourcefile or die "Cannot open source! $!\n"; open (TARGET, ">:encoding(utf8)", "$targetfile") or die "Cannot open target file! $!\n"; print TARGET <<HTML; <html lang="utf8"> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf8"> ... <form name="myform" method="POST" accept-encoding="UTF-8" accept-chars +et="utf-8" action="$thisprogram"> ... HTML foreach $line (@source) { $line = decode("utf-8", $line);
Note that you may not need to do all of these at once. For example, if you already read the file in as UTF8, there is no need to decode each line of the file as UTF8 again. However, redundancy should have no side effects other than adding a little more bulk to your code.
Blessings,
~ Polyglot ~
|
|---|