31 private function initLcUc( $lcChars, $ucChars, $reinit =
false ) {
32 # bail if we've already done this, unless we are re-initializing
33 if ( !$reinit && $this->lc2uc && $this->uc2lc ) {
37 # split up the lc and uc lists in a unicode-friendly way
39 preg_match_all(
'/./u', $lcChars, $myLc );
43 preg_match_all(
'/./u', $ucChars, $myUc );
46 # map lc to uc and vice versa
47 $this->lc2uc = array_combine( array_values( $myLc ), array_values( $myUc ) );
48 $this->uc2lc = array_combine( array_values( $myUc ), array_values( $myLc ) );
63 private function addMappings( $mapArray, &$A2B, &$B2A, $exactCase =
false,
64 $prePat =
'', $postPat =
'' ) {
65 foreach ( $mapArray as $WordA => $WordB ) {
67 $ucA = $this->
myUc( $WordA );
68 $ucWordA = $this->
myUcWord( $WordA );
69 $ucB = $this->
myUc( $WordB );
70 $ucWordB = $this->
myUcWord( $WordB );
73 # if there are regexes, only map toward backregs
74 if ( !preg_match(
'/\$[1-9]/', $WordA ) ) {
75 $A2B[ $prePat . $WordA . $postPat ] = $WordB;
77 $A2B[ $prePat . $ucWordA . $postPat ] = $ucWordB;
78 $A2B[ $prePat . $ucA . $postPat ] = $ucB;
82 if ( !preg_match(
'/\$[1-9]/', $WordB ) ) {
83 $B2A[ $prePat . $WordB . $postPat ] = $WordA;
85 $B2A[ $prePat . $ucWordB . $postPat ] = $ucWordA;
86 $B2A[ $prePat . $ucB . $postPat ] = $ucA;
93 # init lc and uc, as needed
94 $this->
initLcUc( $lcChars, $ucChars );
96 # no regex prefix/suffix needed
99 $this->Latn2CyrlExceptions, $this->Cyrl2LatnExceptions );
101 $this->Cyrl2LatnExceptions, $this->Latn2CyrlExceptions );
103 $this->Cyrl2LatnExceptions, $this->Latn2CyrlExceptions,
true );
105 # load C2L and L2C bidirectional affix mappings
107 $this->Cyrl2LatnPatterns, $this->Latn2CyrlPatterns,
false,
'/' . self::WB,
'/u' );
109 $this->Cyrl2LatnPatterns, $this->Latn2CyrlPatterns,
false,
'/', self::WB .
'/u' );
111 # tack on one-way mappings to the ends of the prefix and suffix patterns