CGI character set display
Posted: Wed Jul 19, 2017 3:57 pm
For some of my CGIs, I have to enter Chinese characters to them.
After migrating to RHEL 7, I started using UTF8 over Big5 due to the higher acceptance of UTF8. Also, Apache is sort of forcing to use UTF8 for uniform behavior.
Here is an example of entering Chinese character and Big5 shows garbage codes:
Entering:
but got
The way to correct this is to change the code from
to:
After making the change, the new output becomes readable:
and data can be written to database (MySQL) then.
After migrating to RHEL 7, I started using UTF8 over Big5 due to the higher acceptance of UTF8. Also, Apache is sort of forcing to use UTF8 for uniform behavior.
Here is an example of entering Chinese character and Big5 shows garbage codes:
Entering:
Code: Select all
For 蕭家緯(Chia-Wei Hsiao)
entering grade 一年級(1st Grade)
Registration Fee:
$35.00
Tuition:
$470.00
Books / Material:
$20.00
PVA Annual Membership:
$15.00
CCCA Annual Membership:
$20.00
Grand Total:
$560.00
Code: Select all
For �剖振蝺�(Chia-Wei Hsiao) entering grade 銝�撟渡�(1st Grade) Registration
Fee: $35.00 Tuition: $470.00 Books / Material: $20.00 PVA Annual Membership:
$15.00 CCCA Annual Membership: $20.00 Grand Total: $560.00
Code: Select all
print $cgi->header(-charset => 'Big5');
Code: Select all
print $cgi->header(-charset => 'UTF8');
Code: Select all
For 蕭家緯(Chia-Wei Hsiao) entering grade 一年級(1st Grade) Registration Fee: $35.00 Tuition: $470.00 Books / Material: $20.00 PVA Annual Membership: $15.00 CCCA Annual Membership: $20.00 Grand Total: $560.00