Hi, I'm stumped by this problem - I hope someone can help me.

I'm replacing "bad" characters in HTML files.

An example of the sort of characters that I'm replacing is:

Ÿ (Not sure how that will come out - it appears as a square box in my source file but appears to get converted to Ÿ on here)

I've got it in my code as:

from => qq{Ÿ}, to => q{Ÿ},
However, I'd really like to be able to produce the from "string" programatically, i.e. represent it using pure ascii character.

I've hex-dumped the source file and the thing between the {} appears as:

000018c0 20 20 46 72 6f 6d 20 20 3d 3e 20 71 71 7b c2 9f | From = +> qq{..|
i.e. the character is represented by the c2 9f hex digits.

If I do a test script, and do something like:

binmode(STDOUT, ":utf8"); my $teststring = qq{Ÿ}; print "$teststring\n";
And pipe the output to hexdump, I see that $teststring has 4 characters:

c3 82 c2 9f
So, how do I produce a data structure that holds exactly the same content as "from => qq{Ÿ}" without having the binary character in my source code?

Thanks for any help. R.

--

Robin Bowes | http://robinbowes.com


In reply to Representing "binary" character in code? by robinbowes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.