Advertisement
Guest User

Untitled

a guest
Oct 21st, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.49 KB | None | 0 0
  1.  
  2.  
  3. function encode_gsm($string){
  4.  
  5. $dict = array(
  6.  '@' => "\\\\x00",
  7.  '£' => "\\\\x01",
  8.  '$' => "\\\\x02",
  9.  '¥' => "\\\\x03",
  10.  'è' => "\\\\x04",
  11.  'é' => "\\\\x05",
  12.  'ù' => "\\\\x06",
  13.  
  14. //NON FONCTIONNEL
  15.  'ì' => "\\\\x07",
  16.  'ò' => "\\\\x08",
  17.  'Ç' => "\\\\x09",
  18.  
  19.  'Ø' => "\\\\x0B",
  20.  'ø' => "\\\\x0C",
  21.  'Å' => "\\\\x0E",
  22.  'å' => "\\\\x0F",
  23.  
  24. //NON FONCTIONNEL
  25.  'Δ' => "\\\\x10",
  26.  
  27.  '_' => "\\\\x11",
  28.  'Φ' => "\\\\x12",
  29.  'Γ' => "\\\\x13",
  30.  'Λ' => "\\\\x14",
  31.  'Ω' => "\\\\x15",
  32.  'Π' => "\\\\x16",
  33.  'Ψ' => "\\\\x17",
  34.  'Σ' => "\\\\x18",
  35.  'Θ' => "\\\\x19",
  36.  'Ξ' => "\\\\x1A",
  37.  'Æ' => "\\\\x1C",
  38.  'æ' => "\\\\x1D",
  39.  'ß' => "\\\\x1E",
  40.  'É' => "\\\\x1F",
  41.  
  42.  // all \\\\x2? removed
  43.  // all \\\\x3? removed
  44.  // all \\\\x4? removed
  45.  'Ä' => "\\\\x5B",
  46.  'Ö' => "\\\\x5C",
  47.  'Ñ' => "\\\\x5D",
  48.  'Ü' => "\\\\x5E",
  49.  '§' => "\\\\x5F",
  50.  
  51.  '¿' => "\\\\x60",
  52.  
  53.  'ä' => "\\\\x7B",
  54.  'ö' => "\\\\x7C",
  55.  'ñ' => "\\\\x7D",
  56.  'ü' => "\\\\x7E",
  57.  'à' => "\\\\x7F",
  58.  
  59.  '^' => "\\\\x1B\\\\x14",
  60.  '{' => "\\\\x1B\\\\x28",
  61.  '}' => "\\\\x1B\\\\x29",
  62.  '\\\\' => "\\\\x1B\\\\x2F",
  63.  '[' => "\\\\x1B\\\\x3C",
  64.  '~' => "\\\\x1B\\\\x3D",
  65.  ']' => "\\\\x1B\\\\x3E",
  66.  '|' => "\\\\x1B\\\\x40",
  67.  '€' => "\\\\x1B\\\\x65"
  68. );
  69.  
  70.  
  71. $converted = strtr($string, $dict);
  72.  
  73. // Replace unconverted UTF-8 chars from codepages U+0080-U+07FF, U+0080-U+FFFF and U+010000-U+10FFFF with a single ?
  74.     return preg_replace('/([\\xC0-\\xDF].)|([\\xE0-\\xEF]..)|([\\xF0-\\xFF]...)/m','?',$converted);
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement