I wrote a simple web script to add some (UTF-8 encoded) texts into database. Somehow is there a bug which i can't find. I simplified it to bones and it still does not work.
When i enter plain ascii, it is OK. When i enter Latin1 diacritics like "öä", they turn out like "��". When i try use somethin outside of Latin1, it turns to "Internal server error" and from log i see: "Cannot decode string with wide characters at /usr/lib/perl/5.10/Encode.pm line 162."
As far as i see, i have data properly encoded and headers define charset right way. I put test ( is_utf8() ) in script and it yells "1" to log. So where is the glitch here?
#!/usr/bin/perl use strict; use locale; use utf8; use open ':std' => ':encoding(UTF-8)'; use CGI qw(:all -utf8); my $q = new CGI; my %p = $q->Vars; warn utf8::is_utf8($p{text}); # says: 1 warn $p{text}; # shows uglified chars in log too print $q->header(-type=>"text/html", -charset=>"UTF-8"); print $q->start_html(-encoding=>"UTF-8"); print $q->pre( $p{text} ); print $q->p("some pretty UTF-8 formed characters: öäüõžš¢ð€¶"), $q->start_form, $q->textarea('text', '' , 10, 40), $q->br, $q->submit('view', 'view'), $q->end_form, $q->end_html;
TIA,
In reply to Confusing UTF-8 bug in CGI-script by wanradt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |