'SMS unicode defining whith french accents utf8_decode

In an sms gateway I want to determinate if an sms should be counted and considered as plain or as unicode I'm using this code

if (strlen($sms) != strlen(utf8_decode($sms))) {
                    if ($msg_type == 'plain' || $msg_type == 'voice' || $msg_type == 'mms') {
                        $msg_type = 'unicode';
                    }

It's working fine but it's including also french accents as é à è counting sms containing them as unicode but it shouldn't

Any idea to make an exception for these 3 letters é è à so it doesn't count sms as unicode if it contains them ?

Many thank



Solution 1:[1]

Any idea to make an exception for these 3 letters é è à so it doesn't count sms as unicode if it contains them ?

Replace them with e and a, before you do your "plain" vs. unicode string length comparison.

$smsModified = str_replace(['à', 'é', 'è'], ['a', 'e', 'e'], $sms);
if (strlen($smsModified) != strlen(utf8_decode($smsModified))) { ... }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CBroe