in reply to Re^2: Representing "binary" character in code?
in thread Representing "binary" character in code?
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:
If I hexdump the file, the same fragment looks like this:| <a href="/2/about.html">About Us</a> | <a href="/2/service.h +tml">We <U+0092>re About Service</a>
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 - ’ in this case.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<|
Here's some more code. This is how I am generating the rules, and using the utf8 character:
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.my @rules = ( { From => qq{<92>}, To => q{’}, Flags => q{he}, }
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Representing "binary" character in code?
by graff (Chancellor) on Nov 06, 2006 at 02:27 UTC |