MediaWiki
REL1_20
|
00001 <?php 00030 class LanguageEo extends Language { 00062 function iconv( $in, $out, $string ) { 00063 if ( strcasecmp( $in, 'x' ) == 0 && strcasecmp( $out, 'utf-8' ) == 0 ) { 00064 return preg_replace_callback ( 00065 '/([cghjsu]x?)((?:xx)*)(?!x)/i', 00066 array( $this, 'strrtxuCallback' ), $string ); 00067 } elseif ( strcasecmp( $in, 'UTF-8' ) == 0 && strcasecmp( $out, 'x' ) == 0 ) { 00068 # Double Xs only if they follow cxapelutaj literoj. 00069 return preg_replace_callback( 00070 '/((?:[cghjsu]|\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]|\xc5[\x9c\x9d\xac\xad])x*)/i', 00071 array( $this, 'strrtuxCallback' ), $string ); 00072 } 00073 return parent::iconv( $in, $out, $string ); 00074 } 00075 00080 function strrtuxCallback( $matches ) { 00081 static $ux = array ( 00082 'x' => 'xx' , 'X' => 'Xx' , 00083 "\xc4\x88" => "Cx" , "\xc4\x89" => "cx" , 00084 "\xc4\x9c" => "Gx" , "\xc4\x9d" => "gx" , 00085 "\xc4\xa4" => "Hx" , "\xc4\xa5" => "hx" , 00086 "\xc4\xb4" => "Jx" , "\xc4\xb5" => "jx" , 00087 "\xc5\x9c" => "Sx" , "\xc5\x9d" => "sx" , 00088 "\xc5\xac" => "Ux" , "\xc5\xad" => "ux" 00089 ); 00090 return strtr( $matches[1], $ux ); 00091 } 00092 00097 function strrtxuCallback( $matches ) { 00098 static $xu = array ( 00099 'xx' => 'x' , 'xX' => 'x' , 00100 'Xx' => 'X' , 'XX' => 'X' , 00101 "Cx" => "\xc4\x88" , "CX" => "\xc4\x88" , 00102 "cx" => "\xc4\x89" , "cX" => "\xc4\x89" , 00103 "Gx" => "\xc4\x9c" , "GX" => "\xc4\x9c" , 00104 "gx" => "\xc4\x9d" , "gX" => "\xc4\x9d" , 00105 "Hx" => "\xc4\xa4" , "HX" => "\xc4\xa4" , 00106 "hx" => "\xc4\xa5" , "hX" => "\xc4\xa5" , 00107 "Jx" => "\xc4\xb4" , "JX" => "\xc4\xb4" , 00108 "jx" => "\xc4\xb5" , "jX" => "\xc4\xb5" , 00109 "Sx" => "\xc5\x9c" , "SX" => "\xc5\x9c" , 00110 "sx" => "\xc5\x9d" , "sX" => "\xc5\x9d" , 00111 "Ux" => "\xc5\xac" , "UX" => "\xc5\xac" , 00112 "ux" => "\xc5\xad" , "uX" => "\xc5\xad" 00113 ); 00114 return strtr( $matches[1], $xu ) . strtr( $matches[2], $xu ); 00115 } 00116 00121 function checkTitleEncoding( $s ) { 00122 # Check for X-system backwards-compatibility URLs 00123 $ishigh = preg_match( '/[\x80-\xff]/', $s ); 00124 $isutf = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . 00125 '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ); 00126 00127 if ( $ishigh and !$isutf ) { 00128 # Assume Latin1 00129 $s = utf8_encode( $s ); 00130 } else { 00131 if ( preg_match( '/(\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]' . 00132 '|\xc5[\x9c\x9d\xac\xad])/', $s ) ) 00133 return $s; 00134 } 00135 00136 // if( preg_match( '/[cghjsu]x/i', $s ) ) 00137 // return $this->iconv( 'x', 'utf-8', $s ); 00138 return $s; 00139 } 00140 00141 function initEncoding() { 00142 global $wgEditEncoding; 00143 $wgEditEncoding = 'x'; 00144 } 00145 }