GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Fold(3) User Contributed Perl Documentation Fold(3)

Lingua::JA::Fold - to fold a Japanese text.

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

This module is used to fold a Japanese text 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'. Width and 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 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 fold a Japanese text is rather complicate thing.

fold('text' => $text, 'length' => $i [, 'mode' => $mode])
Function. To fold a string within specified length of $i.

The way in which to calculate length is differs by a mode.

 'full-width' : culculated for a full-width character.
 'traditional': culculated for a full-width character; reflects traditional manner of composition.
 (not given)  : igore size difference between a full and a half.
    
The Japanese Traditional Manner of Composition
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 all of these marks are full-width Japanese characters.

length_half($text)
Function. Exportable. This is for counting length of a text for a half-width character.
length_full($text)
Function. Exportable. This is for counting length of a text for a full-width character.
tab2space('text' => $text, 'space' => $i)
Function. Exportable. To replace a [TAB] character in a text with given number of [SPACE]s.
kana_half2full($text)
Function. Exportable. To convert a character in a text from half-width 'Kana' to full-width one.

module: utf8
module: Encode

This module runs under Unicode/UTF-8 environment (hence Perl5.8 or later is required), you should input text as UTF-8 flaged string. Specify the "use utf8;" pragma in your source code and use utf8::decode() method to UTF-8 flag on.

Masanori HATA <http://www.mihr.net/> (Saitama, JAPAN)

Copyright ©2003-2008 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.

Hey! The above document had some coding errors, which are explained below:
Around line 32:
Non-ASCII character seen before =encoding in ''アイウエオ'. Assuming CP1252
2008-03-19 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.