Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> iso-8859-2 to utf-8
Silverstorm
post
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 19.01.2005

Ostrzeżenie: (10%)
X----


[fixed]

Ten post edytował Silverstorm 30.03.2009, 14:20:18
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Speed666
post
Post #2





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 17.01.2005

Ostrzeżenie: (0%)
-----


ze strony php5.pl

  1. <?php
  2. define('UTF8_TO_ISO88592', 1);
  3. define('ISO88592_TO_UTF8', 2);
  4. define('WIN1250_TO_UTF8', 3);
  5. define('UTF8_TO_WIN1250', 4);
  6. define('ISO88592_TO_WIN1250', 5);
  7. define('WIN1250_TO_ISO88592', 6);
  8.  
  9. // skrypt ze strony http://php5.pl
  10. function plCharset($string, $type = ISO88592_TO_UTF8) {
  11.  
  12. $win2utf = array(
  13. "xb9" => "xc4x85", "xa5" => "xc4x84",
  14. "xe6" => "xc4x87", "xc6" => "xc4x86",
  15. "xea" => "xc4x99", "xca" => "xc4x98",
  16. "xb3" => "xc5x82", "xa3" => "xc5x81",
  17. "xf3" => "xc3xb3", "xd3" => "xc3x93",
  18. "x9c" => "xc5x9b", "x8c" => "xc5x9a",
  19. "x9f" => "xc5xbc", "x8f" => "xc5xbb",
  20. "xbf" => "xc5xba", "xaf" => "xc5xb9",
  21. "xf1" => "xc5x84", "xd1" => "xc5x83"
  22. );
  23. $iso2utf = array(
  24. "xb1" => "xc4x85", "xa1" => "xc4x84",
  25. "xe6" => "xc4x87", "xc6" => "xc4x86",
  26. "xea" => "xc4x99", "xca" => "xc4x98",
  27. "xb3" => "xc5x82", "xa3" => "xc5x81",
  28. "xf3" => "xc3xb3", "xd3" => "xc3x93",
  29. "xb6" => "xc5x9b", "xa6" => "xc5x9a",
  30. "xbc" => "xc5xbc", "xac" => "xc5xbb",
  31. "xbf" => "xc5xba", "xaf" => "xc5xb9",
  32. "xf1" => "xc5x84", "xd1" => "xc5x83"
  33. );
  34.  
  35. if ($type == ISO88592_TO_UTF8)
  36. return strtr($string, $iso2utf);
  37. if ($type == UTF8_TO_ISO88592)
  38. return strtr($string, array_flip($iso2utf));
  39. if ($type == WIN1250_TO_UTF8)
  40. return strtr($string, $win2utf);
  41. if ($type == UTF8_TO_WIN1250)
  42. return strtr($string, array_flip($win2utf));
  43. if ($type == ISO88592_TO_WIN1250)
  44. return strtr($string, "xa1xa6xacxb1xb6xbc",
  45. "xa5x8cx8fxb9x9cx9f");
  46. if ($type == WIN1250_TO_ISO88592)
  47. return strtr($string, "xa5x8cx8fxb9x9cx9f",
  48. "xa1xa6xacxb1xb6xbc");
  49. }
  50. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 27.12.2025 - 06:21