{"id":2669,"date":"2013-03-11T14:29:41","date_gmt":"2013-03-11T14:29:41","guid":{"rendered":"http:\/\/www.simonbattersby.com\/blog\/?p=2669"},"modified":"2014-03-02T14:18:27","modified_gmt":"2014-03-02T14:18:27","slug":"exporting-to-csv-ae-replacingl","status":"publish","type":"post","link":"https:\/\/www.simonbattersby.com\/blog\/2013\/03\/exporting-to-csv-ae-replacingl\/","title":{"rendered":"Exporting to csv &#8211; \u00e2\u20ac\u2122 replacing &#8216;"},"content":{"rendered":"<p>Came across an interesting and frustrating issue last week. A client was exporting selected data from a WordPress database (actually using <a href=\"http:\/\/wordpress.org\/extend\/plugins\/export-users-to-csv\/\">this plugin<\/a>), and the user was seeing odd characters in the csv output. The most obvious was the replacement of single apostrophes: &#8216; with this: \u00e2\u20ac\u2122.<\/p>\r\n<p>Clearly an encoding problem but I couldn&#8217;t immediately see why. Pages displaying the data were fine, web pages and the database were all set to use <code>utf-8<\/code>. I finally solved the problem by forcing the encoding of the csv file via:<\/p>\r\n<pre>$text = mb_convert_encoding($text,'windows-1252');<\/pre>\r\n<p>Hope this helps someone else&#8230;<\/p>\r\n\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>Came across an interesting and frustrating issue last week. A client was exporting selected data from a WordPress database (actually using this plugin), and the user was seeing odd characters in the csv output. The most obvious was the replacement of single apostrophes: &#8216; with this: \u00e2\u20ac\u2122. Clearly an encoding problem but I couldn&#8217;t immediately [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-2669","post","type-post","status-publish","format-standard","hentry","category-web-design-and-build"],"_links":{"self":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/posts\/2669","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/comments?post=2669"}],"version-history":[{"count":6,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/posts\/2669\/revisions"}],"predecessor-version":[{"id":2681,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/posts\/2669\/revisions\/2681"}],"wp:attachment":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/media?parent=2669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/categories?post=2669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/tags?post=2669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}