I've had a look around and can't find a definite answer to my problem.
Basically I have an SMS gateway I am using. To send GSM, chinese, arabic etc characters through their SMS gateway, I have to send the message as 16-bit unicode.
What I want to do is detect if the message will require to be sent as 16-bit unicode or just plain old 7-bit for simple English characters. All my characters are stored in UTF-8.
Here is my code that I am using to detect this:
if (preg_match("/^[a-zA-Z0-9 !@#$%^&*()-_+={\[\]}|\\`<>,.\?\/]*$/u", $string) == 1)
return '7-bit';
else
return '16-bit';
I've uploaded some test cases here: http://phpfiddle.org/lite/code/v7f-gi0 (just hit the Run button)
The code seems really messy to me. Am I going about this the wrong way?