ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: Kolotov Alexandr <akmypost@mail.ru>
To: community@altlinux.ru
Subject: Re: [Comm] Re: TkInter - русофоб
Date: Fri, 14 Jan 2005 11:44:19 +0300
Message-ID: <41E78663.9010103@mail.ru> (raw)
In-Reply-To: <41E6F048.2050803@mtu-net.ru>

>>>    Программируя в TkInter в Python (под Citron 2.4) делаю окно Text и 
>>> начинаю выводить туда текст с русскими буквами.и вижу нечто 
>>> нечитаемое. Кто-нибудь умеет выводить русский текст в TkInter корректно?
>>> Поделитесь опытом., а?
>> В юникоде. Никаких проблем. Других кодировок Tk, AFAIK, больше не 
>> умеет, я даже с кем-то
>> из разработчиков Tk трепался об этом, если я правильно помню.
> А есть возможность "на лету" (в самой программе) переделать koi-8/cp1251 
> в юникод?
умеет...

пример из книги "Язык программирование Python" Г. Россум, Ф.Л.Дж. Дрейк, 
Д.С. Откидач

Если у Вас есть данные в определенной кодировке, для получения строки 
UNICODE используйте встроенную функцию unicode(), указав кодировку в 
качестве второго аргумента

 >>> s = unicode("Привет", "KOI8-R")
 >>> s
u'\u041F\u0440\u0438\u0432\u0435\u0442'

Метод encode() позволяет преобразовывать строки Unicode в обычные 
строки, содержащие текст в указанной кодировке:

 >>> s.encode("KOI8-R")
'\360\322\327\305\324'
 >>> s.encode("UTF-8")
'\320\237\321\200\320\270\320\262\320\265\321\202'

-- 
С уважением, Kolotov Alexandr aka mr. Эбола
              отвечать: akmypost@mail.ru
                   ICQ: 100349254

    ---------------------------------------
   |  Registered Linux user       # 236664 |
    ---------------------------------------



      parent reply	other threads:[~2005-01-14  8:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-13  8:39 [Comm] " Oleg N. Kayunov
2005-01-13 10:00 ` vadim_r
2005-01-13 20:05   ` [Comm] " Oleg N. Kayunov
2005-01-14  8:47     ` Kolotov Alexandr
2005-01-13 20:58 ` [Comm] " Andrey Orlov
2005-01-13 22:03   ` [Comm] " Oleg N. Kayunov
2005-01-14  0:36     ` Andrey Orlov
2005-01-14  6:32     ` Guest007
2005-01-14  8:44     ` Kolotov Alexandr [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=41E78663.9010103@mail.ru \
    --to=akmypost@mail.ru \
    --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