Lingua::JA::Fold - fold a Japanese text.
use Lingua::JA::Fold qw(fold tab2space kana_half2full);
my $text = 'ï½±ï½²ï½³ï½´ï½µ æ¼¢å—';
# replace a [TAB] with 4 of [SPACE]s.
$text = tab2space('text' => $text, 'space' => 4);
# convert a half-width 'Kana' character to a full-width one.
$text = kana_half2full($text);
# fold the text under 2 full-width characters par a line.
$text = fold('text' => $text, 'length' => 2);
# output the result
This module is used for Japanese text wrapping and so on.
The Japanese (the Chinese and the Korean would be the same) text has traditionally unique manner in representing. Basically those characters are used to be represented in two kind of size which is 'full-width' or 'half-width'. The width and the height of full-width characters are the same size (regular square). At the point, it is different from the alphabet characters which have normally variable (slim) width in representing. Roughly say, we call the width of alphabet characters and Arabic numbers as a half, and do the width of other characters as a full. In a Japanese text which is mixed with alphabet and Arabic numbers, a character has a width, it would be full or half.
For such reasons, to wrap Japanese text is rather complicate thing.
Function. Fold a string within the specified length of $i.
The way in which to calculate length is differs by a mode.
'full-width' : culculate for a full-width character.
'traditional': culculate for a full-width character; reflects the traditional manner of composition.
(not given) : igore the size difference between a full and a half.
This formal manner is another saying as the forbidden rule. The rule is: 1) a termination mark like Ten "," and Maru ".", 2) a closing mark -- brace or parenthesis or bracket -- like ")", "}", "]", ">" and etc., 3) a repeat mark, those should not be placed at the top of a line. If it would be occured, such mark should be moved to the next to the bottom of the previous line.
Actually by this module what is detect as a forbidden mark are listed next:
Note that these marks are all full-width Japanese characters.
Function. Exportable. This is for counting the length of a text for a half-width character.
Function. Exportable. This is for counting the length of a text for a full-width character.
Function. Exportable. Replace a [TAB] character in a text with given number of [SPACE]s.
Function. Exportable. Convert a character in a text from half-width 'Kana' to full-width one.
This module runs under Unicode/UTF-8 environment (hence Perl5.8 or later is required), you should input text as a UTF-8 flaged string. Specify the use utf8; pragma in your source code and use utf8::decode() method to UTF-8 flag on a string.
Masanori HATA <firstname.lastname@example.org> (Saitama, JAPAN)
Copyright (c) 2003-2004 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:
Non-ASCII character seen before =encoding in ''ï½±ï½²ï½³ï½´ï½µ'. Assuming CP1252
To install Lingua::JA::Fold, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.