The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Lingua::JA::Fold - fold Japanese text

SYNOPSIS

 use utf8;
 use Lingua::JA::Fold;
 
 my $text = 'アイウエオ    漢字';
 my $obj = Lingua::JA::Fold->new($text);
 
 # replace a [TAB] with 4 of [SPACE]s.
 $obj->tab2space(4);
 # convert half-width 'Kana' characters to full-width ones.
 $obj->kana_half2full;
 
 # fold the text under 2 full-width characters par a line.
 $obj->fold(2);
 
 # result
 print $obj->output;

DESCRIPTION

This module is used for Japanese text wrapping and so on.

Japanese (Chinese and Korean would be the same) text has traditionally unique manner in printing. Basically those characters are used to be printed in the two size of 'full-width' or 'half-width'. The full-width characters' width and height are about the same size (regular square). At this point, it is different from the alphabet characters which have normally variable width in printing. Roughly say, we call the width of alphabet letters and Arabic numbers as half, and do the width of other characters as full. In a Japanese text which is mixed with alphabet and Arabic numbers, a character's width is full or half.

Thus manner seems to make text wrapping rather complicate thing.

METHODS

new($string)

This is the class constructor method of the module.

output

This method outputs the string.

fold($i)

This method folds the string within the specified length of $i in full-width.

tab2space($i)

This method replaces [TAB] with some [SPACE]s of $i in the string.

kana_half2full

This method converts from half-width 'Kana's to full-width ones in the string.

length_full($text)

This method is for counting length of the $text in full-width.

length_half($text)

This method is for counting length of the $text in half-width.

SEE ALSO

module: utf8
module: Encode

NOTES

This module runs under Unicode/UTF-8 environment (hence Perl5.8 or later is required), you should input octets with UTF-8 charset. Please use utf8; pragma to enable to detect strings as UTF-8 in your source code.

TO DO

Support to reflect rule of the forbidden marks.

AUTHOR

Masanori HATA <lovewing@geocities.co.jp> (Saitama, JAPAN)

COPYRIGHT

Copyright (c) 2003 Masanori HATA. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 167:

Non-ASCII character seen before =encoding in ''アイウエオ'. Assuming CP1252