00001 <?php
00002
00007 class LanguageEo extends Language {
00008 function iconv( $in, $out, $string ) {
00009 # For most languages, this is a wrapper for iconv
00010 # Por multaj lingvoj, ĉi tiu nur voku la sisteman funkcion iconv()
00011 # Ni ankaŭ konvertu X-sistemajn surogotajn
00012 if( strcasecmp( $in, 'x' ) == 0 and strcasecmp( $out, 'utf-8' ) == 0) {
00013 $xu = array (
00014 'xx' => 'x' , 'xX' => 'x' ,
00015 'Xx' => 'X' , 'XX' => 'X' ,
00016 "Cx" => "\xc4\x88" , "CX" => "\xc4\x88" ,
00017 "cx" => "\xc4\x89" , "cX" => "\xc4\x89" ,
00018 "Gx" => "\xc4\x9c" , "GX" => "\xc4\x9c" ,
00019 "gx" => "\xc4\x9d" , "gX" => "\xc4\x9d" ,
00020 "Hx" => "\xc4\xa4" , "HX" => "\xc4\xa4" ,
00021 "hx" => "\xc4\xa5" , "hX" => "\xc4\xa5" ,
00022 "Jx" => "\xc4\xb4" , "JX" => "\xc4\xb4" ,
00023 "jx" => "\xc4\xb5" , "jX" => "\xc4\xb5" ,
00024 "Sx" => "\xc5\x9c" , "SX" => "\xc5\x9c" ,
00025 "sx" => "\xc5\x9d" , "sX" => "\xc5\x9d" ,
00026 "Ux" => "\xc5\xac" , "UX" => "\xc5\xac" ,
00027 "ux" => "\xc5\xad" , "uX" => "\xc5\xad"
00028 ) ;
00029 return preg_replace ( '/([cghjsu]x?)((?:xx)*)(?!x)/ei',
00030 'strtr( "$1", $xu ) . strtr( "$2", $xu )', $string );
00031 } else if( strcasecmp( $in, 'UTF-8' ) == 0 and strcasecmp( $out, 'x' ) == 0 ) {
00032 $ux = array (
00033 'x' => 'xx' , 'X' => 'Xx' ,
00034 "\xc4\x88" => "Cx" , "\xc4\x89" => "cx" ,
00035 "\xc4\x9c" => "Gx" , "\xc4\x9d" => "gx" ,
00036 "\xc4\xa4" => "Hx" , "\xc4\xa5" => "hx" ,
00037 "\xc4\xb4" => "Jx" , "\xc4\xb5" => "jx" ,
00038 "\xc5\x9c" => "Sx" , "\xc5\x9d" => "sx" ,
00039 "\xc5\xac" => "Ux" , "\xc5\xad" => "ux"
00040 ) ;
00041 # Double Xs only if they follow cxapelutaj literoj.
00042 return preg_replace( '/((?:[cghjsu]|\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'.
00043 '|\xc5[\x9c\x9d\xac\xad])x*)/ei', 'strtr( "$1", $ux )', $string );
00044 }
00045 return iconv( $in, $out, $string );
00046 }
00047
00048 function checkTitleEncoding( $s ) {
00049 # Check for X-system backwards-compatibility URLs
00050 $ishigh = preg_match( '/[\x80-\xff]/', $s);
00051 $isutf = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
00052 '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
00053
00054 if($ishigh and !$isutf) {
00055 # Assume Latin1
00056 $s = utf8_encode( $s );
00057 } else {
00058 if( preg_match( '/(\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'.
00059 '|\xc5[\x9c\x9d\xac\xad])/', $s ) )
00060 return $s;
00061 }
00062
00063
00064
00065 return $s;
00066 }
00067
00068 function initEncoding() {
00069 global $wgEditEncoding;
00070 $wgEditEncoding = 'x';
00071 }
00072 }