6

normsms

normsms
SYNOPSIS

normsms($s)

DESCRIPTION

normsms returns a copy of $s where a character with an accent not supported by the GSM 03.38 norm is replaced by a flat character and different combinations of \r and \n are replaced by a single \r.

CODE
  1. function normsms($s) {
  2.     /* GSM 03.38
  3.      @  £  $   ¥  è  é  ù  ì  ò  Ç  ?   Ø  ø  CR  Å  å
  4.      ?  _   ?   ?   ?   ?   ?   ?   ?   ?   ?   ?   Æ  æ  ß  É
  5.      SP !   "   #   €     %   &   '   (   )   *   +   ,   -   .
  6.      0  1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?
  7.      ¡     A   B   C   D   E   F   G   H   I   J   K   L   M   N
  8.      P  Q   R   S   T   U   V   W   X   Y   Z   Ä  Ö  Ñ  Ü  §
  9.      ¿     a   b   c   d   e   f   g   h   i   j   k   l   m   n
  10.      p  q   r   s   t   u   v   w   x   y   z   ä  ö  ñ  ü  à
  11.      */
  12.     $from = array(
  13.                 "\r\n", "\n\r", "\n",
  14.                 'â', 'á', 'ã',
  15.                 'î', 'ï', 'í',
  16.                 'ô', 'ó', 'õ',
  17.                 'û', 'ú',
  18.                 'ê', 'ë',
  19.                 'ç',
  20.                 'À', 'Â', 'Á', 'Ã',
  21.                 'Î', 'Ï', 'Ì', 'Í',
  22.                 'Ô', 'Ò', 'Ó', 'Õ',
  23.                 'Ù', 'Û', 'Ú',
  24.                 'È', 'Ê', 'Ë',
  25.                 '`',
  26.                 '[', ']',   //  '[', ']', '{', '}', '~', '\\',
  27.     );
  28.  
  29.     $to = array(
  30.                 "\r", "\r", "\r",
  31.                 'a', 'a', 'a',
  32.                 'i', 'i', 'i',
  33.                 'o', 'o', 'o',
  34.                 'u', 'u',
  35.                 'e', 'e',
  36.                 'c',
  37.                 'A', 'A', 'A', 'A',
  38.                 'I', 'I', 'I', 'I',
  39.                 'O', 'O', 'O', 'O',
  40.                 'U', 'U', 'U',
  41.                 'E', 'E', 'E',
  42.                 "'",
  43.                 '(', ')',   //  '(', ')', '(', ')', '-', '/',
  44.     );
  45.  
  46.     $gsmset = array(
  47.                 '@', '£', '$', '¥', 'è', 'é', 'ù', 'ì', 'ò', 'Ç', 'Ø', 'ø', "\r", 'Å', 'å',
  48.                 '_', 'Æ', 'æ', 'ß', 'É',
  49.                 ' ', '!', '"', '#', '€', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/',
  50.                 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
  51.                 '¡', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
  52.                 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ä', 'Ö', 'Ñ', 'Ü', '§',
  53.                 '¿', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
  54.                 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'ä', 'ö', 'ñ', 'ü', 'à',
  55.                 '[', ']', '{', '}', '~', '^', '|', '\\',
  56.     );
  57.  
  58.     return preg_replace('/[^' . preg_quote(implode($gsmset), '/') . ']/', '.', str_replace($from, $to, $s));
  59. }
SEE ALSO

filtersms, strflat

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].