perl-5.38.0
lc EXPR
lc

Returns a lowercased version of EXPR. If EXPR is omitted, uses $_.

EXPR を小文字に変換したものを返します。 EXPR が省略されると、$_ を使います。

    my $str = lc("Perl is GREAT"); # "perl is great"

What gets returned depends on several factors:

返り値として得られるものは色々な要素に依存します:

If use bytes is in effect:

(use bytes が有効の場合)

The results follow ASCII rules. Only the characters A-Z change, to a-z respectively.

結果は ASCII の規則に従います。 A-Z のみが変換され、それぞれ a-z になります。

Otherwise, if use locale for LC_CTYPE is in effect:

(それ以外の場合で、LC_CTYPE に対して use locale が有効の場合)

Respects current LC_CTYPE locale for code points < 256; and uses Unicode rules for the remaining code points (this last can only happen if the UTF8 flag is also set). See perllocale.

符号位置 < 256 に対しては現在の LC_CTYPE ロケールに従います; そして 残りの符号位置に付いては Unicode の規則を使います (これは UTF8 フラグも 設定されている場合にのみ起こります)。 perllocale を参照してください。

Starting in v5.20, Perl uses full Unicode rules if the locale is UTF-8. Otherwise, there is a deficiency in this scheme, which is that case changes that cross the 255/256 boundary are not well-defined. For example, the lower case of LATIN CAPITAL LETTER SHARP S (U+1E9E) in Unicode rules is U+00DF (on ASCII platforms). But under use locale (prior to v5.20 or not a UTF-8 locale), the lower case of U+1E9E is itself, because 0xDF may not be LATIN SMALL LETTER SHARP S in the current locale, and Perl has no way of knowing if that character even exists in the locale, much less what code point it is. Perl returns a result that is above 255 (almost always the input character unchanged), for all instances (and there aren't many) where the 255/256 boundary would otherwise be crossed; and starting in v5.22, it raises a locale warning.

v5.20 から、ロケールが UTF-8 の場合は Perl は完全な Unicode の規則を使います。 さもなければ、この手法には、255/266 の境界をまたぐ大文字小文字の変換は 未定義であるという欠点があります。 例えば、Unicode での LATIN CAPITAL LETTER SHARP S (U+1E9E) の小文字は (ASCII プラットフォームでは) U+00DF です。 しかし use locale が有効(v5.20 より前か、UTF-8 ロケール以外)なら、U+1E9E の 小文字は自分自身です; なぜなら 0xDF は現在のロケールでは LATIN SMALL LETTER SHARP S ではなく、Perl は例えこのロケールに文字が 存在するかどうかを知る方法がなく、ましてどの符号位置かを知る方法が ないからです。 Perl は 255/256 境界をまたぐ全ての(多くはありません)実体については (ほとんど常に入力文字を変更せずに)256 以上の値を返します; そして v5.22 から locale 警告を出力します。

Otherwise, If EXPR has the UTF8 flag set:

(その他の場合で、EXPR に UTF8 フラグがセットされている場合)

Unicode rules are used for the case change.

大文字小文字変換には Unicode の規則が使われます。

Otherwise, if use feature 'unicode_strings' or use locale ':not_characters' is in effect:

(それ以外の場合で、use feature 'unicode_strings'use locale ':not_characters' が有効の場合)

Unicode rules are used for the case change.

大文字小文字変換には Unicode の規則が使われます。

Otherwise:

(それ以外の場合)

ASCII rules are used for the case change. The lowercase of any character outside the ASCII range is the character itself.

大文字小文字変換には ASCII の規則が使われます。 ASCII の範囲外の文字の「小文字」はその文字自身です。

Note: This is the internal function implementing the \L escape in double-quoted strings.

注意: これは、ダブルクォート文字列における、 \L エスケープを実装する 内部関数です。

    my $str = "Perl is \LGREAT\E"; # "Perl is great"