PHP and Character Sets

I’ve been trying to get WordPress’s post-by-email feature to work with image attachments. After a couple days of hacking (1.5 days of groping around in the dark, and half a day of hacking), I have mostly succeeded. 

Please hold your applause.

The catch is, it isn’t handling text in Japanese, posted from a Japanese cell phone. A minor inconvenience, but it happens to be my current itch, and I’m scratching it.

Turns out that PHP and its support for character sets is even worse than advertised. Here are some links and notes for my own future reference:

iconv is the old standby, but it doesn’t help all that much. MBstring looks like it will help me figure out what the current encoding of the string is.

Wish me luck while I figure this out.

UPDATE: MBstring works like a charm. Japanese phones use SHIFT_JIS internally but the email servers they use encode in ISO-2022-jp. And here is a nice lucid explanation of the Japanese encoding systems in common use: iso-2022-jp, Shift-JIS, and EUC-JP — although be aware that it is quite old, 1996, and predates widespread acceptance of Unicode.

Thoughts on WordPress 2.7

There was a release of the new WordPress this weekend, and it looks and performs great. I’ve been working on upgrading the blogs that I manage, and I am really thrilled about the fact that I’ll never have to do it this way again–2.7 includes a self-upgrade tool.

2.7 has support for Child Themes.  Here are some notes to myself as I attempt to develop some themes for friends:

  • Sample Blog data comes in handy for testing. More here.
  • offers their blog themes for a fee, but they are GPL’d so there are unsupported links on each of their theme pages. (I was a pretty happy customer of their 1.0 theme.)
  • Themeshaper has the low-down on child themes, because he wrote the spec for child themes that eventually got folded into 2.7. His theme “Thematic” seems to be the cats pajamas for a good place to start for theme development. (Thematic turns out to be rich and complex and based on stuff in the Sandbox theme’s post and class semantic markup.)
  • Some helpful info about the specific changes to themes in 2.7: ericulous and bloggingtips.


Strange how I’ve come around on PHP, and WordPress. But they both manage to hit a sweet spot for the projects that I want to do in my spare time, on my cheap (but awesome) hosting service. More on that another time.

svn: ‘wp-content/plugins/akismet’ is not a working copy

Maybe you’ve been upgrading your WordPress installation using the Subversion method (sweet and easy! if you like the command line). If so, in the update to v2.6.1 or so, perhaps you’ve gotten this error message:

Fetching external item into ‘wp-content/plugins/akismet’
svn: ‘wp-content/plugins/akismet’ is not a working copy
svn: Can’t open file ‘wp-content/plugins/akismet/.svn/entries’: No such file or directory

Yeah, me too.

This isn’t a big deal, btw. Your wordpress installation will work just fine, it’s just more of an annoyance. Below I explain how to remove it.


Previously, the WP guys used Subversions “externals” feature to pull in the akismet plugin automaticall from a different part of their subversion repository. In v2.6, the Plugin upgrade system was added, and now Akismet can be upgraded from the admin interface. So they removed the svn property that brought in the Akismet code because it was not needed any longer. This is what caused the error message.

Update: Actually, I just created a new blog, and it is pulling Akismet in via the svn:externals. So I am not sure exactly what happened–it seems to be an issue from an existing SVN install, being updated to 2.6.1 or above. Strange. Anyway, the “fix” below seems to be sufficient, if you don’t mind upgrading Akismet via the admin UI.

To fix it:

1. in a terminal window, change directories so that you are in the wp-content/plugins directory.


2. remove the svn:externals property.

Your shell commands will look something like this:


$ cd blog/wp-content/plugins


$ svn propget svn:externals 


$ svn propdel svn:externals

property ‘svn:externals’ deleted from ‘.’.




Update Akismet from inside WP

Now you get to use WP’S snazzy new plugin update features. In your admin, go to the Plugins section. If you haven’t already done the upgrade, there will be an upgrade notice beneath the Akismet Plugin information.

Click “upgrade automatically” to activate the update. Easy!