LanguageEo.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /** Esperanto (Esperanto)
  3. *
  4. * @ingroup Language
  5. */
  6. class LanguageEo extends Language {
  7. function iconv( $in, $out, $string ) {
  8. # For most languages, this is a wrapper for iconv
  9. # Por multaj lingvoj, ĉi tiu nur voku la sisteman funkcion iconv()
  10. # Ni ankaŭ konvertu X-sistemajn surogotajn
  11. if( strcasecmp( $in, 'x' ) == 0 and strcasecmp( $out, 'utf-8' ) == 0) {
  12. $xu = array (
  13. 'xx' => 'x' , 'xX' => 'x' ,
  14. 'Xx' => 'X' , 'XX' => 'X' ,
  15. "Cx" => "\xc4\x88" , "CX" => "\xc4\x88" ,
  16. "cx" => "\xc4\x89" , "cX" => "\xc4\x89" ,
  17. "Gx" => "\xc4\x9c" , "GX" => "\xc4\x9c" ,
  18. "gx" => "\xc4\x9d" , "gX" => "\xc4\x9d" ,
  19. "Hx" => "\xc4\xa4" , "HX" => "\xc4\xa4" ,
  20. "hx" => "\xc4\xa5" , "hX" => "\xc4\xa5" ,
  21. "Jx" => "\xc4\xb4" , "JX" => "\xc4\xb4" ,
  22. "jx" => "\xc4\xb5" , "jX" => "\xc4\xb5" ,
  23. "Sx" => "\xc5\x9c" , "SX" => "\xc5\x9c" ,
  24. "sx" => "\xc5\x9d" , "sX" => "\xc5\x9d" ,
  25. "Ux" => "\xc5\xac" , "UX" => "\xc5\xac" ,
  26. "ux" => "\xc5\xad" , "uX" => "\xc5\xad"
  27. ) ;
  28. return preg_replace ( '/([cghjsu]x?)((?:xx)*)(?!x)/ei',
  29. 'strtr( "$1", $xu ) . strtr( "$2", $xu )', $string );
  30. } else if( strcasecmp( $in, 'UTF-8' ) == 0 and strcasecmp( $out, 'x' ) == 0 ) {
  31. $ux = array (
  32. 'x' => 'xx' , 'X' => 'Xx' ,
  33. "\xc4\x88" => "Cx" , "\xc4\x89" => "cx" ,
  34. "\xc4\x9c" => "Gx" , "\xc4\x9d" => "gx" ,
  35. "\xc4\xa4" => "Hx" , "\xc4\xa5" => "hx" ,
  36. "\xc4\xb4" => "Jx" , "\xc4\xb5" => "jx" ,
  37. "\xc5\x9c" => "Sx" , "\xc5\x9d" => "sx" ,
  38. "\xc5\xac" => "Ux" , "\xc5\xad" => "ux"
  39. ) ;
  40. # Double Xs only if they follow cxapelutaj literoj.
  41. return preg_replace( '/((?:[cghjsu]|\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'.
  42. '|\xc5[\x9c\x9d\xac\xad])x*)/ei', 'strtr( "$1", $ux )', $string );
  43. }
  44. return iconv( $in, $out, $string );
  45. }
  46. function checkTitleEncoding( $s ) {
  47. # Check for X-system backwards-compatibility URLs
  48. $ishigh = preg_match( '/[\x80-\xff]/', $s);
  49. $isutf = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
  50. '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
  51. if($ishigh and !$isutf) {
  52. # Assume Latin1
  53. $s = utf8_encode( $s );
  54. } else {
  55. if( preg_match( '/(\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'.
  56. '|\xc5[\x9c\x9d\xac\xad])/', $s ) )
  57. return $s;
  58. }
  59. //if( preg_match( '/[cghjsu]x/i', $s ) )
  60. // return $this->iconv( 'x', 'utf-8', $s );
  61. return $s;
  62. }
  63. function initEncoding() {
  64. global $wgEditEncoding;
  65. $wgEditEncoding = 'x';
  66. }
  67. }