ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: Dmitriy Ryzhov <dryzhov@bibirevo.net>
To: community@altlinux.ru
Subject: [Comm]  Сортировка кириллицы в Perl
Date: Sun, 15 Jun 2003 16:12:44 +0400
Message-ID: <134104998980.20030615161244@bibirevo.net> (raw)
In-Reply-To: <20030614143156.7C796E31CF@master.altlinux.ru>

Привет!

Просветите плз, что за глюки такие? Перл глючит с юникодом или я?

ALT Linux Sisyphus (20030605). perl-5.8.0-alt1. Локаль - CP1251.

1. Сортировка:
#!/usr/bin/perl -w

use strict;
use POSIX;
use locale;
use encoding 'cp1251';

my @l1 = ("п", "р", "с", "т");
my @l2 = qw(п р с т);
print "$_(", ord, ") " foreach sort(@l1); print "\n";
print "$_(", ord, ") " foreach sort(@l2); print "\n";

Вывод:
п(1087) т(1090) с(1089) р(1088) //?!
п(1087) р(1088) с(1089) т(1090)

Комментирую строку "use encoding 'cp1251'" - всё ок (строки уже в
utf-8 не хранятся):
п(239) р(240) с(241) т(242)
п(239) р(240) с(241) т(242)

Проверил под Windows XP (Perl 5.8.0 от ActiveState) - без "use encoding"
вроде глючит, с ней:
п(1087) т(1090) с(1089) р(1088)
п(1087) т(1090) с(1089) р(1088)

2. Регулярные выражения без учета регистра:
print("аБвгд" =~ m/б/i? "1": "0", "\n");
print("абвгд" =~ m/б/i? "1": "0", "\n");
print(lc("аБвгд") =~ m/б/? "1":"0", "\n");

Вывод:
0
0
1

Без "use encoding 'cp1251'" - опять всё ок: 1 1 1
Под Windows всё точно также.

Как всё это объясняется? В доках вроде ничего не нашел.
-- 
Best regards,
 Dmitriy Ryzhov                            mailto:dryzhov@bibirevo.net


  reply	other threads:[~2003-06-15 12:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-09 20:47 [Comm] конфигурялка для iptables Николай
2003-06-10  1:07 ` [Comm] " Oleg N. Kayunov
2003-06-13 20:37   ` [Comm] " Николай
2003-06-14 10:05     ` Sergey Degtyaryov
2003-06-14 14:30     ` Grigory Tuboltsev
2003-06-15 12:12       ` Dmitriy Ryzhov [this message]
2003-07-13 13:04       ` [Comm] Re[3]: " Николай
2003-07-13 13:20         ` Shrek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=134104998980.20030615161244@bibirevo.net \
    --to=dryzhov@bibirevo.net \
    --cc=community@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git