I'm trying to make a list of my recent posts, and truncate the titles (so they all fit nicely in a box) using this code:
It works perfectly, except that post titles with brackets or dashes, basically any special character, somehow mess up the character count. For example, it seems like a ( is worth two characters, and a ' is worth four.
I'm using courier new as the font, so any character length discrepancy is immediately visible, because all characters are the same width.
Basically I need the 'strlen' function to count the post title characters as they appear in the browser.