Here's the situation:
I have an HTML form. When its contents are submitted to a perl script, any non-ASCII characters come out wrongly encoded, for instance if I type 'I like Beyoncé' it comes out in my script as 'I like Beyoncé'
The script does some other stuff, AJAX was involved at one point, but I have now reduced it to a simple (POST or GET) request to this script:
use CGI::Simple; my $q = CGI::Simple->new(); print "Content-type: text/plain\n\n"; print $q->param('text');
And if the 'text' parameter contains anything double-byte/UTF-8, I get that output.
Things I have tried:
But still the problem persists. What else can I do?
Confusingly, this page: https://www.i18nqa.com/debug/utf8-debug.html seems to suggest my errant character, é turning into é is caused by Windows-1252 encoding, a.k.a. ISO 8859-1, but this is nothing to do with Windows. It's happening on OS X for a start.
TIA, fellow monks
SOLVED: This is what worked:
use Encode; print Encode::decode_utf8($q->param('text'))
I guess I just have to accept that when the text leaves URL A it might be UTF-8 but there's no way to tell page B that, and I will always have to decode it.
In reply to [SOLVED] How do I convince my Perl script that UTF-8 from an HTML form really is UTF-8? by Cody Fendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |