How can I accurately calculate the number of characters in a string with special characters using PHP?
<p>I'm using <code>strlen</code> to calculate the length of a string and if it exceeds x characters, <code>substr</code> it with a ellipses. The problem is, if there are special characters, the <code>strlen</code> function spits out an inaccurate number, causing ellipses to be added to strings that haven't exceeded x characters. What is a good method of calculating the length of a string in a way that works even with special characters involved, preferably counting a special character as a regular character so something like "W^a" counts as three characters.</p>
