File tree 2 files changed +27
-4
lines changed
2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -342,14 +342,20 @@ public function utf8ToUnicode($str)
342
342
}
343
343
344
344
if ($ thisValue >= 128 ) {
345
- if (count ($ values ) == 0 ) {
346
- $ lookingFor = ($ thisValue < 224 ) ? 2 : 3 ;
345
+ if (count ($ values ) === 0 ) {
346
+ $ lookingFor = 2 ;
347
+
348
+ if ($ thisValue >= 240 ) {
349
+ $ lookingFor = 4 ;
350
+ } elseif ($ thisValue >= 224 ) {
351
+ $ lookingFor = 3 ;
352
+ }
347
353
}
348
354
349
355
$ values [] = $ thisValue ;
350
356
351
- if (count ($ values ) == $ lookingFor ) {
352
- $ number = ($ lookingFor == 3 ) ?
357
+ if (count ($ values ) === $ lookingFor ) {
358
+ $ number = ($ lookingFor === 3 ) ?
353
359
(($ values [0 ] % 16 ) * 4096 ) + (($ values [1 ] % 64 ) * 64 ) + ($ values [2 ] % 64 ) :
354
360
(($ values [0 ] % 32 ) * 64 ) + ($ values [1 ] % 64 );
355
361
Original file line number Diff line number Diff line change @@ -180,6 +180,23 @@ public function testUnicode()
180
180
$ this ->assertEquals ($ expected , $ count );
181
181
}
182
182
183
+ public function testUnicodeEmoji ()
184
+ {
185
+ $ text = '😎😎 ' ;
186
+
187
+ $ smsCounter = new SMSCounter ();
188
+ $ count = $ smsCounter ->count ($ text );
189
+
190
+ $ expected = new \stdClass ();
191
+ $ expected ->encoding = SMSCounter::UTF16 ;
192
+ $ expected ->length = 2 ;
193
+ $ expected ->per_message = 70 ;
194
+ $ expected ->remaining = 68 ;
195
+ $ expected ->messages = 1 ;
196
+
197
+ $ this ->assertEquals ($ expected , $ count );
198
+ }
199
+
183
200
public function testRemoveNonGSMChars ()
184
201
{
185
202
$ text = 'áno-unicode-remaining` ñ ' ;
You can’t perform that action at this time.
0 commit comments