in reply to Re^6: Encoding/decoding question
in thread Encoding/decoding question
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Encoding/decoding question
by slugger415 (Monk) on Sep 12, 2011 at 21:46 UTC | |
| [reply] |
by tchrist (Pilgrim) on Sep 13, 2011 at 00:46 UTC | |
The problem is in your original XHTML file, because it has the literal 12‑byte ASCII sequenceI am processing some XHTML pages (using XML::Twig) that contain numerous character entities, such as:Sorry to be dumb here, but where am I treating it as Latin-1? How do I change it? This may have happened because some program read an undecoded binary byte stream and never decoded it before trying to convert non‑ASCII into numeric entities. For example, here I use -CS in the first process to say it’s UTF‑8 but then lie to the second one by using -C0 to say that it isn’t. That would produce the sort of thing that you saw: Compare with the right answers: So what you really need to do is track down whatever errant procedure caused this mess in the first place, and fix that, since it will never work right that way. This demonstrates putting it back to UTF-8: And this, heaven help you, demonstrates doing that and then doing the entities the right way around in the first place: That means that if you were courageous enough, you could just do this: Here’s a version that runs from as a script instead of from the command line: No warantees, though. Make sure you thoroughly understand all this before you further mangle your files. | [reply] [d/l] [select] |