3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
26 class LanguageJa
extends Language
{
28 /** Space string for hiragana - unicode range U3040-309f */
29 private const WORD_SEG_HIRAGANA
= '(?:\xe3(?:\x81[\x80-\xbf]|\x82[\x80-\x9f]))';
31 /** Space string for katakana - unicode range U30a0-30ff */
32 private const WORD_SEG_KATAKANA
= '(?:\xe3(?:\x82[\xa0-\xbf]|\x83[\x80-\xbf]))';
34 /** Space string for kanji - unicode range U3200-9999 = \xe3\x88\x80-\xe9\xa6\x99 */
35 private const WORD_SEG_KANJI
=
36 '(?:\xe3[\x88-\xbf][\x80-\xbf]|[\xe4-\xe8][\x80-\xbf]{2}|\xe9[\x80-\xa5][\x80-\xbf]|\xe9\xa6[\x80-\x99])';
38 private const WORD_SEGMENTATION_REGEX
=
39 '/(' . self
::WORD_SEG_HIRAGANA
. '+|' . self
::WORD_SEG_KATAKANA
. '+|' . self
::WORD_SEG_KANJI
. '+)/';
41 public function segmentByWord( $string ) {
42 return self
::insertSpace( $string, self
::WORD_SEGMENTATION_REGEX
);
46 * Italic is not appropriate for Japanese script.
47 * Unfortunately, most browsers do not recognise this, and render `<em>` as italic.
52 public function emphasize( $text ) {