ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: Sergey Vlasov <vsu@mivlgu.murom.ru>
To: mandrake-russian@altlinux.ru
Subject: Re: [mdk-re] Вопрос по локали...
Date: Fri Sep 28 17:53:01 2001
Message-ID: <20010928180154.7b4bb00c.vsu@mivlgu.murom.ru> (raw)
In-Reply-To: <00e101c14724$ee94abc0$0700a8c0@sapfir.spb.ru>

On Thu, 27 Sep 2001 11:20:45 +0400
"Serge Ivanoff" <SergeIV@mail.ru> wrote:

> В результате долгих раскопок выяснилось что функция isprintable() не
> воспринимает русские буквы.
> т.е судя по описанию набор символов которые она воспринимает как
> печатабельные зависит от локали - в русской локали должно воспринимать
> русские буквы. А вот и не работает.
> Кто наступал на это? Как решили проблему?

Ничего подобного:

#include <stdio.h>
#include <ctype.h>
#include <locale.h>

int main(void)
{
        int ch;

        setlocale(LC_ALL, "");

        while ((ch = getchar()) != EOF) {
                if (isprint(ch))
                        printf("0x%02x: printable\n", ch);
                else
                        printf("0x%02x: unprintable\n", ch);
        }
        return 0;
}

$ gcc test.c
$ locale
LANG=ru_RU.KOI8-R
LC_CTYPE="ru_RU.KOI8-R"
LC_NUMERIC="ru_RU.KOI8-R"
LC_TIME="ru_RU.KOI8-R"
LC_COLLATE="ru_RU.KOI8-R"
LC_MONETARY="ru_RU.KOI8-R"
LC_MESSAGES="ru_RU.KOI8-R"
LC_PAPER="ru_RU.KOI8-R"
LC_NAME="ru_RU.KOI8-R"
LC_ADDRESS="ru_RU.KOI8-R"
LC_TELEPHONE="ru_RU.KOI8-R"
LC_MEASUREMENT="ru_RU.KOI8-R"
LC_IDENTIFICATION="ru_RU.KOI8-R"
LC_ALL=
$ ./a.out 
abc абв      
0x61: printable
0x62: printable
0x63: printable
0x20: printable
0xc1: printable
0xc2: printable
0xd7: printable
0x0a: unprintable
$ LC_ALL=C ./a.out 
abc абв   
0x61: printable
0x62: printable
0x63: printable
0x20: printable
0xc1: unprintable
0xc2: unprintable
0xd7: unprintable
0x0a: unprintable

Возможно, проблема в том, что при обработке обычной строки
(массива char) параметры isxxxx() нужно преобразовывать к типу
unsigned char - иначе получаются отрицательные значения, которые
действительно не обрабатываются. isxxxx() обрабатывает коды от
0x00 до 0xFF, а также EOF (-1); кстати, tolower() и toupper()
ведут себя точно так же.



      parent reply	other threads:[~2001-09-28 17:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-27 11:02 Serge Ivanoff
2001-09-28  1:33 ` Roman S
2001-09-28  9:52   ` [mdk-re] " Serge Ivanoff
2001-09-28 21:22   ` [mdk-re] " Mikhail Zabaluev
2001-09-28 22:23     ` Roman S
2001-09-28 22:37       ` Aleksey Novodvorsky
2001-09-28 23:09         ` Roman S
2001-09-29 12:47           ` Sergey Vlasov
2001-09-29 19:18             ` Roman S
2001-09-28 17:53 ` Sergey Vlasov [this message]

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=20010928180154.7b4bb00c.vsu@mivlgu.murom.ru \
    --to=vsu@mivlgu.murom.ru \
    --cc=mandrake-russian@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