2

filtersms

filtersms
SYNOPSIS

filtersms($s)

CODE
  1. function filtersms($s) {
  2.     $charset7bit = "@£\$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà";
  3.     $charset7bitext = "\f^{}\\[~]|€";
  4.  
  5.     $s = preg_replace('/\R/', "\r\n", trimsms($s));
  6.  
  7.     if (preg_match('/[^' . preg_quote($charset7bit . $charset7bitext, '/') . ']/', $s)) {
  8.         $coding='16bit';
  9.         $maxlen=70;
  10.         $extlen=67;
  11.     }
  12.     else {
  13.         $coding='7bit';
  14.         $maxlen=160;
  15.         $extlen=153;
  16.  
  17.         $s = preg_replace('/([' . preg_quote($charset7bitext, '/') . '])/u', "\e\\1", $s);
  18.     }
  19.  
  20.     $msglen = mb_strlen($s, 'UTF-8');
  21.  
  22.     if ($msglen > $maxlen) {
  23.         $count = 1 + floor($msglen / $extlen);
  24.         $len = $count * $extlen;
  25.     }
  26.     else {
  27.         $count = 1;
  28.         $len = $maxlen;
  29.     }
  30.  
  31.     return array($s, $coding, $msglen, $count, $len);
  32. }
  33.  
  34. function trimsms($s) {
  35.     return preg_replace('/ *(\R)+/', '\1', preg_replace('/^ /m', '', preg_replace('/[ \t]+/', ' ', trim($s))));
  36. }
SEE ALSO

normsms

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].