By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,818 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,818 IT Pros & Developers. It's quick & easy.

How to overcome automatic cyrillic-to-/hex convert

P: n/a
Hi friends,

I am really sorry to bother you with such a simple stupid question but
today it's my second day spent in searching manuals, mail-archives
(I downloaded over 100MB from "python-list"),
etc., and I could not find anything that can solve the matter.

I am from Bulgaria and I use Python (+wxPython+Boa Constructor) as a
front-end to database processing with Firebird. I use Python 2.4.1 over
Windows 98 SE. My keyboard is set as default Bulgarian keyboard (keybg)
so I can write in Bulgarian using win32 application as well in MS DOS
prompt. That should correspond to 'cp1251' (win32) and 'cp855' (DOS
console) encodings.

But when I enter some Bulgarian (actually cyrillic) text as a string,
it
seems that Python automatically converts it to '\x00..\x00 ' and once
converted that way I can't get it back into its original look. The only
way to get it right is using print :
a = '明明' # 'Mam' in Bulgarian
print a '明明'

but
a

'\xcc\xe0\xec\xe0'

It is not such a great problem that the string enters or gets out of
the
database in that look as long as the user doesn't see it. But when it
comes to data visualization I can't expect the user to know what
'\xcc\xe0\xec\xe0' mean, neither can I use (at least as much as I know)
'print' for that job. To visualize data in the base I use table views
created with wxGrid. In the grid instead of '明明' I am getting
'\xcc\xe0\xec\xe0'.

To set the value of a particular cell in the grid I use
wxGrid::SetCellValue :

self.grid1.SetCellValue(row, column, string)

In one of O'Reilly's Python books (Learning Python, chapter 8.3.2)there
is a hint that it is possible to redirect the standard output to a
user-defined object but it is not quite clear how that can be achived
and if that is applicable in my case at all.

Your help is of great need and would be truely appreciated!

Thank you very much!

degoor
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
<de***********@dir.bg> <de***********@dir.bg> wrote:
But when I enter some Bulgarian (actually cyrillic) text as a string,
it
seems that Python automatically converts it to '\x00..\x00 ' and once
converted that way I can't get it back into its original look. The only
way to get it right is using print :
a = '明明' # 'Mam' in Bulgarian
print a '明明'

but
a

'\xcc\xe0\xec\xe0'

Did you try the locale module?
Florian
--
begin signature_virus
Hi! I'm a signature virus. Please copy me to your signature to help me spread.
end
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.