Detecting sms charset using gsm charset.
sms-charset-detector helps you to detect whether your sms content contains gsm charset symbols only or not.
Install package with Composer:
> composer require um/sms-charset-detector
Simple usage:
use Um\CharsetDetector\BasicCharsetDetector;
$detector = new BasicCharsetDetector();
$message = 'Some message to be sent over sms';
$encoding = $detector->detectCharset($message);
echo $encoding; // outputs either 'gsm' or 'ucs'
// simple check if charset is 'gsm'
$messageHasGsmCharset = $detector->isGsmCharset($message);
var_dump($messageHasGsmCharset); // outputs either `true` or `false`