NAME

ShiftJIS::LineBreak - Perl module to break a string to lines.


SYNOPSIS

  use ShiftJIS::LineBreak;
    @lines = ShiftJIS::LineBreak::bytebreak($str, 70, " ");
    @lines = ShiftJIS::LineBreak::linebreak($str, 70, 2, " ");


DESCRIPTION

This Perl module provides some functions to break a Shift_JIS string into lines.

bytebreak(STRING, BYTE)
bytebreak(STRING, BYTE, PADDING)
Breaks the specified string into a string list by the specified length in bytes.

If PADDING (that should be a single-byte character) is specified, the lines are padded by that character.

linebreak(STRING, BYTE)
linebreak(STRING, BYTE, MARGIN)
linebreak(STRING, BYTE, MARGIN, PADDING)
linebreak(STRING, BYTE, MARGIN, PADDING, NUMBER)
Breaks the specified string into lines by the specified length in bytes. By default, Kinsoku (prohibition of line break) is executed (see also setkinsoku()).

CR, LF and CRLF cause a line to break there even if short. To each line broken, \n is appended. The length of \n is not included in BYTE.

The whitespace characters at the line-top are deleted.

If MARGIN is specified in bytes, the Kinsoku characters are pushed into the previous line if possible.

If PADDING is specified, the lines are padded by that character. The padding should be a single-byte character; otherwise padding is not executed.

If NUMBER is specified as a positive number, breaking lines is executed until the number of broken lines reaches it and the remainder part is appended to the returned list. The remainder part is neither padded by the padding character nor appended by \n.

    ($folded, $remainder) = sjstring::linebreak($str, 70, 2, " ", 1);

If NUMBER is zero, less than zero, or unspecified, breaking lines is executed till last.

setkinsoku(EXPR)
You can change the Kinsoku level used by linebreak() in the range between 0 and 31 (the initial value is 7).
   Kinsoku  Kind of Punctuation
     1      parentheses and quotes (excluding C<'> and C<">)
     2      sentence-end punctuations
     4      Small Kana, Prolonged Sound Mark and Iteration Marks
     8      unit and currency symbols
    16      no break between alphanumeric characters


AUTHOR

Tomoyuki SADAHIRO

  bqw10602@nifty.com
  http://homepage1.nifty.com/nomenclator/perl/
  This program is free software; you can redistribute it and/or 
  modify it under the same terms as Perl itself.


SEE ALSO

perl(1).