目錄

名稱

I18N::Collate - 根據目前區域設定比較 8 位元標量資料

語法

use I18N::Collate;
setlocale(LC_COLLATE, 'locale-of-your-choice');
$s1 = I18N::Collate->new("scalar_data_1");
$s2 = I18N::Collate->new("scalar_data_2");

說明

  ***

  WARNING: starting from the Perl version 5.003_06
  the I18N::Collate interface for comparing 8-bit scalar data
  according to the current locale

	HAS BEEN DEPRECATED

  That is, please do not use it anymore for any new applications
  and please migrate the old applications away from it because its
  functionality was integrated into the Perl core language in the
  release 5.003_06.

  See the perllocale manual page for further information.

  ***

此模組提供物件,這些物件會根據您的國家/地區字元集進行對照,前提是您的系統支援 POSIX setlocale() 函式。

您可以使用下列方式比較 $s1 和 $s2:

$s1 le $s2

若要擷取資料本身,您需要解除參考:$$s1

此模組使用 POSIX::setlocale()。基本對照轉換是由 strxfrm() 執行的,strxfrm() 會在 NUL 字元終止,這是一個不錯的 C 常式。collate_xfrm() 會優雅地處理內嵌 NUL 字元。

可用的區域設定會依您的作業系統而定;請嘗試 locale -a 是否會顯示這些區域設定,或查看「locale」、「nlsinfo」的手冊頁,或直接使用 ls /usr/lib/nls/locls /usr/lib/nlsls /usr/lib/locale。供應商支援的所有區域設定不一定都會安裝:請參閱作業系統的文件,並可能諮詢您的當地系統管理員。區域設定名稱可能是類似 xx_XX.(ISO)?8859-Nxx_XX.(ISO)?8859N 的字串,例如 fr_CH.ISO8859-1 是法語 (fr) 的瑞士 (CH) 變體,ISO 拉丁 (8859) 1 (-1) 是西歐字元集。