OK, I've had another stab at this.

I used wget to pull down the proxied page that shows the problem.

Looking at the html file with less, I see this where the "bad" char is:

| <a href="/2/about.html">About Us</a> | <a href="/2/service.h +tml">We <U+0092>re About Service</a>
If I hexdump the file, the same fragment looks like this:

00002110 2f 32 2f 73 65 72 76 69 63 65 2e 68 74 6d 6c 22 |/2/servic +e.html"| 00002120 3e 57 65 c2 92 72 65 20 0d 0a 20 20 20 20 20 20 |>We..re . +. | 00002130 20 20 41 62 6f 75 74 20 53 65 72 76 69 63 65 3c | About S +ervice<|
Now, if I copy the <U+0092> binary character directly from my browser and paste it into the perl script, the search and replace works - it finds that character and I can replace it with the correct HTML entity - &#8217; in this case.

Here's some more code. This is how I am generating the rules, and using the utf8 character:

my @rules = ( { From => qq{<92>}, To => q{&#8217;}, Flags => q{he}, }
In the example above, <92> is a binary character that shows up in vim as "<92>". If I use less to display the file, it shows up as <U+0092> What I have so far failed to do is to create that binary character programmatically, i.e. using \x{} escapes, or pack(...) or any other techniques.

It seems that if I use the utf8 character directly, perl does the write thing when I print it, but when I try to create the character indirectly I never qute get it right.

R.

--

Robin Bowes | http://robinbowes.com


In reply to Re^3: Representing "binary" character in code? by robinbowes
in thread 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.