I had an odd bug at work the other day. In one of our data reporting systems, the text content for one report was rendering to the browser just fine. But when the same report was exported to PDF using ABCpdf from WebSupergoo some characters were all mangled as shown in the following screenshots:
The messed up PDF output ![]() | The correct browser rendering ![]() |
Well what to do? I didn't even have any idea what the bad characters were but I suspected that they were some sort of UTF-8 abomination of double/single quotes or something of the sort. So here's what I did...
Ah, now we have decimal equivalents for our stange characters. This might be good - where to next? Well, the Replace function sounds like a good bet so I tried...
Text = Text.Replace(Chr(8217), " ' ") which should have replaced the UTF8 appostrophy with the ASCII apostrophy. It didn't ... WTH???!?
After a little more poking around I found out that we need to use ChrW() for character codes in the range < -32768 or > 65535 as described here. Now that we have the right function, our line becomes...
Text = Text.Replace(ChrW(8217), " ' ")
Success!!!! Yeah! Our funky UTF8 apostrophy character now prints as an ASCII appostrophy in our PDF prints.
Thanks for reading!
Adding a Back Button to Concrete5 Template
Remove odd characters from PDF prints in VB.NET
Drag and Drop File Upload with HTML5 and Plupload
Signing Amazon Requests with PHP
The Sciptaculous Autocompleter Disappears in IE!
Coding [6]
coding .net [1]
coding concrete5 [1]
coding php javascript mysql [0]
ExtJS [1]
Family [1]
Flash [2]
Free Stuff [2]
JavaScript [3]
News [1]
Reviews [0]
Reviews Coding [0]
Webusiness [3]
August 2011 [3]
September 2009 [1]
June 2009 [1]
November 2008 [1]
October 2008 [3]
September 2008 [1]
March 2006 [3]