in reply to Escaping double quotes in complete document
I haven't yet had much experience with CGI.pm and UTF-8 issues, so I can't comment much on that, except that using Devel::Peek has been a useful tool for me a few times when dealing with UTF-8 issues, as it helps you see what Perl thinks the string contains. Usually, if you get the encoding right at those points where the data enters and leaves the script, Perl should handle Unicode just fine. Anyway,
the HTML textboxes see the double quote as an end marker for the textbox value
This sounds to me like you might be building your HTML by interpolation, as in print qq{<input type="text" name="foo" value="$val">};? If so, that is certainly the source of the problem and you should use one of the available APIs to write your HTML instead, as they will do the escaping for you. Back before CGI.pm was discouraged, one way to do it was with its HTML generation functions (which are now deprecated). So nowadays the following is not recommended for new scripts, but note how the attribute is properly escaped:
use CGI qw/:html :form/; my $val = q{ "Hello" <world> & }; print textfield('foo',$val), "\n"; __END__ <input type="text" name="foo" value=" "Hello" <world> +&amp; " />
Currently, CGI::HTML::Functions recommends HTML::Tiny, which I haven't yet had the chance to try, and of course there are frameworks like Template::Toolkit or even Mojolicious, although the latter is meant to replace everything that CGI.pm does.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Escaping double quotes in complete document
by MeinName (Novice) on Jun 27, 2017 at 06:34 UTC | |
by haukex (Archbishop) on Jun 27, 2017 at 07:50 UTC | |
by huck (Prior) on Jun 27, 2017 at 07:35 UTC | |
by MeinName (Novice) on Jun 27, 2017 at 10:30 UTC | |
by haukex (Archbishop) on Jun 27, 2017 at 13:42 UTC |