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

Unicode::Precis~[ja] - RFC 7564 PRECISフレームワーク - 実施と比較

SYNOPSIS

  use Unicode::Precis;
  $precis = Unicode::Precis->new(options...);
  $string = $precis->enforce($input);
  $equals = $precis->compare($inputA, $inputB);
  

DESCRIPTION

Unicode::Precis は、PRECISフレームワークに基づいて UTF-8バイト文字列やユニコード文字列の実施と比較を行う。

なお当モジュールは、バイト文字列をアップグレードすることなくUTF-8列として扱う。

Methods

new ( options ... )

コンストラクタUnicode::Precisクラスのインスタンスを作成する。 次のオプションを指定できる。

WidthMappingRule => 'Decomposition'

指定すると、半角および全角のキャラクタをそれらの分解マッピングに変換する (decomposeWidth()を使う)。

AdditionalMappingRule => 'オプション...'

指定すると、空白を変換する。オプション...には次の語 (複数可) を指定できる。

MapSpace

非ASCIIの空白をASCIIの空白に変換する (mapSpace()を使う)。

StripSpace

文字列の始まりや終わりのASCII空白文字を取り除く。

UnifySpace

複数のASCII空白文字の並びを単一のASCII空白文字に変換する。

CaseMappingRule => 'Fold'

指定すると、大文字およびタイトル文字を小文字に変換する (foldCase()を使う)。

NormalizationRule => 'NFC' | 'NFKC' | 'NFD' | 'NFKD'

指定すると、文字列を指定の正規化形式で正規化する。

DirectionalityRule => 'BiDi'

指定すると、右書き文字を含む文字列をBiDi規則で検査する。

StringClass => 'FreeFormClass' | 'IdentifierClass'

指定すると、文字列を指定の文字列クラスで検査する。

OtherRule => $subref

指定すると、文字列を$subrefで参照するサブルーチンの結果によって変換・検査する。

compare ( $stringA, $stringB )

インスタンスメソッド。 文字列を比較する。 両方の文字列の実施が成功すれば、compareExactly() を使って両者を比較し、10を返す。 そうでなければ、undefを返す。

引数$stringA、$stringBは変更されない。

enforce ( $string )

インスタンスメソッド。 文字列の実施を行う。 処理が成功すれば、引数$stringを変更し、それを返す。 そうでなければ、undefを返す。

Exports

なにもエクスポートしない。

CAVEATS

当モジュールが提供できるレパートリは、Perl 本体のユニコードデータベースが提供するものにかぎられる。 この範囲外のキャラクタは、最新版のユニコードで利用可能であっても 「未割り当て」とみなされ、認められない。下表に、Perl の各版が実装するユニコードの版を示す。

  Perl's version     Implemented Unicode version
  ------------------ ---------------------------
  5.8.7, 5.8.8       4.1.0
  5.10.0             5.0.0
  5.8.9, 5.10.1      5.1.0
  5.12.x             5.2.0
  5.14.x             6.0.0
  5.16.x             6.1.0
  5.18.x             6.2.0
  5.20.x             6.3.0

RESTRICTIONS

当モジュールはEBCDICプラットフォームに対応しない。

SEE ALSO

RFC 7564 PRECIS Framework: Preparation, Enforcement, and Comparison of Internationalized Strings in Application Protocols. https://tools.ietf.org/html/rfc7564.

Unicode::BiDiRule~[ja], Unicode::Normalize, Unicode::Precis::Preparation~[ja], Unicode::Precis::Utils.

AUTHOR

Hatuka*nezumi - IKEDA Soji, <hatuka@nezumi.nu>

COPYRIGHT AND LICENSE

Copyright (C) 2015 by Hatuka*nezumi - IKEDA Soji

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. For more details, see the full text of the licenses at <http://dev.perl.org/licenses/>.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.