From: Dmitry Chistikov <dd1email@gmail.com>
To: ALT Linux Community general discussions <community@lists.altlinux.org>
Subject: Re: [Comm] Wammu и кодировка
Date: Tue, 17 Nov 2009 02:25:25 +0300
Message-ID: <2876aabc0911161525q2a02c2c3sacec7f211edc77e0@mail.gmail.com> (raw)
In-Reply-To: <1258409042.8531.9.camel@mikes-ws.shuvaloffs.net>
> Ага, оно. Вот только убей не пойму, почему так. Ведь ср437 не содержит
> кириллицы.
> А так все получилось, спасибо.
Смотрите.
$ f='16/1 "%1x " "\n"'
Вот это - utf8 (символ "ж" представляется парой байт):
$ echo -n ж | hexdump -e "$f"
d0 b6
Вот этот же символ в, скажем, однобайтовой cp1251:
$ echo -n ж | iconv -f utf8 -t cp1251 | hexdump -e "$f"
e6
Здесь проблем нет.
А вот что получится, если неправильно интерпретировать входной поток
байт. Наши два байта задают два символа в какой-нибудь однобайтовой
кодировке, например cp437. Преобразуем вход в utf8:
$ echo -n ж | iconv -f cp437 -t utf8 | hexdump -e "$f"
e2 95 a8 e2 95 a2
Тут на каждый из двух символов потребовалось три байта. Отобразим эти
два символа:
$ echo ж | iconv -f cp437 -t utf8
╨╢
Это как раз наши знакомые.
Итак, жили-были шесть байт:
$ echo -n Муж | hexdump -e "$f"
d0 9c d1 83 d0 b6
(После интерпретации каждого из них как символа в соответствии с cp437
получилось шестнадцать:
$ echo -n Муж | iconv -f cp437 -t utf8 | hexdump -e "$f"
e2 95 a8 c2 a3 e2 95 a4 c3 a2 e2 95 a8 e2 95 a2
...но это разговор отдельный.)
Именно шесть символов, задаваемые (в cp437) исходными байтами, мы и получили:
$ echo Муж | iconv -f cp437 -t utf8
Муж
Как-то так =)
--
Дмитрий Чистиков,
dd1email at gmail dot com
prev parent reply other threads:[~2009-11-16 23:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-15 23:31 Михаил Шувалов
2009-11-16 9:25 ` Michael Shigorin
2009-11-16 10:16 ` Михаил Шувалов
2009-11-16 11:54 ` Michael Shigorin
2009-11-16 21:51 ` Михаил Шувалов
2009-11-16 13:04 ` Sergey Vlasov
2009-11-16 21:58 ` Михаил Шувалов
2009-11-16 18:04 ` Michael A. Kangin
2009-11-16 22:00 ` Михаил Шувалов
2009-11-17 8:46 ` Michael A. Kangin
2009-11-17 14:44 ` Michael Shigorin
2009-11-17 21:41 ` Yuri Bushmelev
2009-11-18 14:41 ` [Comm] [JT] " Michael Shigorin
2009-11-17 22:04 ` [Comm] " Michael A. Kangin
2009-11-16 20:04 ` Dmitry Chistikov
2009-11-16 22:04 ` Михаил Шувалов
2009-11-16 23:25 ` Dmitry Chistikov [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=2876aabc0911161525q2a02c2c3sacec7f211edc77e0@mail.gmail.com \
--to=dd1email@gmail.com \
--cc=community@lists.altlinux.org \
/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