Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Wide Character in Print Warning

by nmork (Novice)
on Oct 09, 2012 at 15:24 UTC ( #998027=perlquestion: print w/replies, xml ) Need Help??
nmork has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a script which generates JSON code based on an arrayref result from a DBI query. To cover issues with special characters (quotes, slashes, etc.) I "escape" them with a library subroutine changing space to %20, etc. (similar to javascript's escape() function) thus I can unescape them with my getJSON ajaxed javascript library function to get back the original data.

All data is ASCII, data fields being encoded can be alpha-numeric primary key type identifiers (like model numbers, serial numbers, etc.)

I am getting "wide character in print" messages when I run this script. There is no wide character in the data--database character encoding is restricted to ASCII. The only thing I can think is somehow I've munged the data to have ascii wide-character representation or one of these key type identifiers coincidentally has ascii wide-character representation.

The only such representation I know of involves backslashes and possibly curly brackets. Is there another representation I could have stumbled across unkowingly?

Here is a block of the ascii data which seems to trigger the message:

{"rpt_hdrrow" : "N", "program_id" : "SCIA410A", "rpt_skiplines" : "N", "gph_numcols" : "%20", "gph_keycols" : "%20", "display_name" : "Daily%20Stock%20In-Out%20Activity%20History", "rpt_rowtot" : "N", "rpt_formatno" : "4", "rpt_oldpvts" : "N", "rpt_nograndtl" : "N", "rpt_pagelines" : "45", "gph_type" : "%20%20%20%20", "rpt_nozeros" : "N", "gph_scaletype" : "%20%20%20%20"} {"rpt_hdrrow" : "N", "program_id" : "SCIA410H", "rpt_skiplines" : "N", "gph_numcols" : "", "gph_keycols" : "", "display_name" : "Daily%20IWide character in print at line + 2366, <CFG_FILE> line 32.nventory%20Detail%20List", "rpt_rowtot" : "N", "rpt_formatno" : "4", "rpt_oldpvts" : "N", "rpt_nograndtl" : "N", "rpt_pagelines" : "45", "gph_type" : "%20%20%20%20", "rpt_nozeros" : "N", "gph_scaletype" : "%20%20%20%20"}

Replies are listed 'Best First'.
Re: Wide Character in Print Warning
by moritz (Cardinal) on Oct 09, 2012 at 15:39 UTC
    I am getting "wide character in print" messages when I run this script. There is no wide character in the data

    Maybe not in the data you get from the database, but surely in the data you print. You find it with something like

    binmode STDOUT, ':encoding(UTF-8)'; print $str =~ /([^\0-\177]+)/g, "\n";

    There are lots of things that can turn ASCII-Data into non-ASCII data, including Encode::decode, JSON decoding and chr.

Re: Wide Character in Print Warning
by daxim (Chaplain) on Oct 09, 2012 at 15:30 UTC
    Hard to tell what you're doing wrong without you showing code. Your percent-encoding is likely botched if you wrote it from scratch/unless you used URI::Escape.

    Inspect those serialised strings with Devel::Peek::Dump.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://998027]
Approved by moritz
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2017-03-23 05:21 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (282 votes). Check out past polls.