8 class LanguageJa
extends Language
{
11 * @param $string string
14 function segmentByWord( $string ) {
15 // Strip known punctuation ?
16 // $s = preg_replace( '/\xe3\x80[\x80-\xbf]/', '', $s ); # U3000-303f
18 // Space strings of like hiragana/katakana/kanji
19 $hiragana = '(?:\xe3(?:\x81[\x80-\xbf]|\x82[\x80-\x9f]))'; # U3040-309f
20 $katakana = '(?:\xe3(?:\x82[\xa0-\xbf]|\x83[\x80-\xbf]))'; # U30a0-30ff
21 $kanji = '(?:\xe3[\x88-\xbf][\x80-\xbf]'
22 . '|[\xe4-\xe8][\x80-\xbf]{2}'
23 . '|\xe9[\x80-\xa5][\x80-\xbf]'
24 . '|\xe9\xa6[\x80-\x99])';
25 # U3200-9999 = \xe3\x88\x80-\xe9\xa6\x99
26 $reg = "/({$hiragana}+|{$katakana}+|{$kanji}+)/";
27 $s = self
::insertSpace( $string, $reg );
32 * Italic is not appropriate for Japanese script
33 * Unfortunately most browsers do not recognise this, and render <em> as italic
38 function emphasize( $text ) {