×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    6

    Font & National Code

    Hi!
    When I use English in the statement like this
    note (u'Hello World!','info') It os OK.
    But when I use my national font. I have abrakadabra.
    note (u'ПРЕВЕД!','info')

    What I must do to get rigth the text for normal view?

  2. #2
    Super Contributor
    Join Date
    May 2004
    Location
    Tampere, Finland
    Posts
    524

    Re: Font & National Code

    Ah, welcome to the wonderful world of character sets.

    Python v2.3 introduced a way to select the source file encoding, like this:

    Code:
    #!/usr/bin/python
    # -*- coding: utf8 -*-
    
    print u"<UNICODE CHARACTERS, ENCODED IN UTF-8>"
    See PEP 0263 for details: http://www.python.org/dev/peps/pep-0263/

    Unfortunately this does not work in Python v2.2, which is the version Python for S60 has. Your editor probably uses UTF-8 or some national character set encoding. Python v2.2 expects ISO-8859-1 characters inside Unicode literals, so you cannot directly use text in your language inside Python for S60 programs. It needs to be expressed using unicode escapes:

    Code:
    import appuifw
    
    appuifw.note(u"\u041f\u0420\u0415\u0412\u0415\u0414!", "info")
    See these Unicode tables for correct character escapes: http://www.unicode.org/charts/

    More information about UTF-8: http://en.wikipedia.org/wiki/Utf-8

  3. #3
    Regular Contributor
    Join Date
    Aug 2004
    Posts
    295

    Re: Font & National Code

    You can of course place the texts inside some other file, and read them from there: open("texts.txt").read().decode("utf-8")

  4. #4
    Registered User
    Join Date
    Jun 2006
    Posts
    6

    Re: Font & National Code

    Thank u for professional help! It is work good.

  5. #5
    Registered User
    Join Date
    Jun 2006
    Posts
    40

    Re: Font & National Code

    hi everybody

    sorry for newbies question...

    would it work with arabic characters ? (on an n-gage)

    thanks

    bye bye

  6. #6
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    Re: Font & National Code

    this is works

    but assume i want to write 1000 char

    by this way
    u041f\u0420\u0415\u0412\u0415\u0414

    i will die before writing my program

  7. #7
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Font & National Code

    I think you should write (the arabic part) into a file and run a script to convert whatever is written in file to UTF-8.

    Then just paste these into your PyS60 code.
    IDEAS is all they need but still they think only Genius can give them that.

  8. #8
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Font & National Code

    So i tried this program and it is giving error

    Code:
    import appuifw
    
    abc=u"ПРЕВЕД"
    	 
    for c in abc:
    	print ord(c)
    And i saved this file with encoding as "UTF-8" (Previously tried with "UTF" also but same error)

    ERROR was


    Traceback (most recent call last): File "Z:\SYstem\Apps|python\default.py", line 81, in menu_action
    f()
    File "Z:\SYstem\Apps|python\default.py", line 65 in query_and_exec execfile(script_list[index][1].encode("utf-8"),script_namespace.namespace)
    File "Z:\SYstem\Apps|python\unicode_try.py", line 1
    IDEAS is all they need but still they think only Genius can give them that.

  9. #9
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Font & National Code

    And one more thing i noticed today was in both of my emulators,
    S60 2nd edition FP2- wins udeb and S60 2nd edition FP2 (debug) and i am not able to display arabic characters beyond "U+064A" as note.
    Is there something wrong because i was looking at arabic unicode characters and they vary from U+0600 to U+06FF.

    http://en.wikipedia.org/wiki/Arabic_Unicode
    IDEAS is all they need but still they think only Genius can give them that.

  10. #10
    Registered User
    Join Date
    Feb 2008
    Location
    Moscow Russia
    Posts
    25

    Re: Font & National Code

    if you wont write russian
    Code:
    def ru(dec):return dec.decode('utf-8')
    and in script
    Code:
    print ru("привет")
    So do in Russia

  11. #11
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    Re: Font & National Code

    hey look my problem is solved

    i used PED 2.19 application

    then define my lang

    def arb(x):return x.decode('utf-8')


    arb('الصقر الذهبي')


    its work my interface of program now in arabic

    (^_^)

Similar Threads

  1. How to get the name of the used font
    By chrishawaii in forum Symbian User Interface
    Replies: 1
    Last Post: 2007-06-22, 06:55
  2. Setting font in Series 60
    By hariprasadth in forum Symbian User Interface
    Replies: 3
    Last Post: 2005-11-10, 12:13
  3. Security code bug on 6230!
    By dabII in forum General Development Questions
    Replies: 1
    Last Post: 2005-05-17, 17:21
  4. New font 6600
    By hamishw in forum Symbian
    Replies: 0
    Last Post: 2005-04-10, 10:59
  5. Replies: 0
    Last Post: 2003-02-24, 04:00

Posting Permissions

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