Patch for /extensions/Hanp/Hanp.body.php =================================================================== '를', # (r)eul '이' => '가', # i, ga '과' => '와', # gwa, wa '은' => '는', # (n)eun ); if ( $dir === self::SOFT ) $map = array_flip( $map ); if ( isset($map[$particle]) ) { return $map[$particle]; } else { return $particle; # We want only valid input, so it is already correct } } static function lastLetterToCodePoint( $string ) { require_once ( dirname( __FILE__ ) . '/php-utf8/utf8.inc' ); $matches = array(); if ( !preg_match( '/.$/u', $string, $matches ) ) return false; // I hate php $returnValue = utf8toUnicode( $matches[0] ); return array_pop( $returnValue ); } static function endsInHangul( $string ) { $rangeStart = hexdec( 'AC00' ); # GA $rangeEnd = hexdec( 'D7A3' ); # HIH $lastLetter = self::lastLetterToCodePoint( $string ); return $rangeStart < $lastLetter && $lastLetter < $rangeEnd; } static function endsInHangulVowel( $string ) { $lastLetter = self::lastLetterToCodePoint( $string ); $candidate = hexdec( 'AC00' ); # GA $increment = hexdec( '1C' ); $lastValue = hexdec( 'D788' ); do { if ( $lastLetter < $candidate ) return false; // Fast out if ( $lastLetter === $candidate ) return true; $candidate += $increment; } while ( $candidate < $lastValue ); return false; } static function endsInHangulRieul( $string ) { $lastLetter = self::lastLetterToCodePoint( $string ); $candidate = hexdec( 'AC08' ); # GA $increment = hexdec( '1C' ); $lastValue = hexdec( 'D790' ); do { if ( $lastLetter < $candidate ) return false; // Fast out if ( $lastLetter === $candidate ) return true; $candidate += $increment; } while ( $candidate < $lastValue ); return false; } static function endsInHangulConsonant( $string ) { return self::endsInHangul( $string ) && !self::endsInHangulVowel( $string ); } }