×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Location
    Moscow, Russia
    Posts
    9

    Question Hello world question

    I'm completely new to Python, so if my question is too amateurish, please forgive me.

    I installed version 1.1.6 and tried this code from manual:

    Code:
    from appuifw import *
    note(u"Hello World!", "info")
    So far, so good. Then I did this:

    Code:
    from appuifw import *
    note(u"Добро пожаловать!", "info")
    The text is in Russian here. And my locale is also Russian.

    When I save the file in UTF-8, interpreter is objecting. When I save it in 1251 or 866 or other code page I see very interesting characters that are not Russian.

    What I did wrong?

  2. #2
    Registered User
    Join Date
    Jul 2005
    Posts
    33
    File .py is the ascii-file ,so that you can't put the Unicode Char. in it ,directly.
    But you can create the Unicode string in .py ,by many ways.
    such as ...

    Using the Python Unicode-Escape encoding
    see this link for detail
    http://docs.python.org/tut/node5.htm...00000000000000
    for example

    from appuifw import *
    note(u'hello and \u041b\u043e\u0431\u0440\u043e \u043f\u043e\u0416\u0430 ', "info")

    or Make text-file in drive E: (for example E:\text.txt ,and save as UTF-8 encoding)
    and Load string from that file like this.

    import codecs
    from appuifw import *
    f=codecs.open(("E:\\text.txt"),mode='r',encoding='utf_8')
    x=f.read()+u'some other text'
    f.close()
    note(x, "info")

  3. #3
    Registered User
    Join Date
    Mar 2003
    Location
    Moscow, Russia
    Posts
    9
    Thanks. I suspected that. I hoped it would be easier to use interpreter.

    Instead, if I need to quickly hack something, I have to think ahead, write additional code, create text resources, sync those additional files, etc, etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×