in reply to Extracting data from Postgres database to XML via Perl - encoding issue

This is not my area of expertise, but I cordially suggest that you should prove your assertion that “it is the carriage-return character that is causing this to happen.”   Because, if you happen to be incorrect (and, I don’t know if you are...), you would have just spent a lot of time chasing a white rabbit red herring.   It should be a simple matter to write a “Perl one-liner” that conclusively proves or disproves your assumption.   There has been many a time when I “knew” what was wrong, and I was dead-wrong.   Once bitten...