The rants and ravings of a Mac developer

I Love programming, Macs, the iPhone, iPad, Apps & iOS! In my spare time I like Programming in ExtJS, PHP, MySQL / SQLite3 and Apache - in other words a Real Geek's geek. I've tinkered around with programing for iOS in the not so distant past . During the day I work for Motorola Solutions in IT as BSA for our Export Compliance system JPMorgan's TradeSphere. At night I freelance program on the Mac & Web. I'm also a techie who likes Sci-Fi and Horror. Some of my favorite authors include Stephen King, William Gibson and Frank Herbert as well as his son Brian Herbert and Kevin Anderson.

But my real passion is for Comic Book Collecting. My current freelance project is writing a web based application using ExtJS for collecting comics books. After I get the web application completed, I will be integrating some portion of the web application into a desktop client for the Mac through the use of web services for all data exchange & transaction. Eventually, the web site & Mac client would also include a social networking component as well as an iOS component.

I started collecting comic books as a kid when my grandfather passed away and we found my father's comic book collection when we were cleaning out my grandfather's basement. There were a number of early issues in that stash, such as Fantastic Four number one, The Amazing Spider-Man number one, number 22 of the Uncanny X-Men... and others. So needless to say, I was hooked.

After high school I stopped collecting - college, drinking and woman took priority (not necessarily in that order) over visiting the local comic book shop. Now that I have 2 kids of my own, I've gotten back into collecting.

Character Sets and PHP Follow Up

Following up to my Feb 23, 2010 post on  difficulties with charaster sets I’ve yet run into another example of how this can mess you up.

In PHP, I was using curl to fetch a page from a remote web server and then extract some data using regex and then inserting it into a MySQL database. The issue that I encountered was that my database was in was in UTF-8 but the text being retrieved from the website was in ISO-8859-1 (aka Latin-1 according to wikipedia). So when I selected a record that had incompatible characters between UTF-8 and ISO-885901 I either saw garbage or truncated values. For example, the value ‘Atlantic Förlags’ on the web page showed up in my table just as ‘Atlantic F’.

So to investigate I used FireFox to open up the URL I was parsing in my PHP script and then right clicked on the web page and selected ‘View Page Info’ from the popup menu.

Now all I needed to do was use PHP’s string iconv(in_charset, out_charset, str) function to convert from ISO-8859-1 to UTF-8 before inserting each string value into my database. Like such:

    $trans_text = iconv("ISO-8859-1", "UTF-8", $text);
 

At least that’s how it goes in theory… your mileage may vary.