×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    4

    Read Text not success

    Hi i want to read a text file but always the result is the same (four or five "boxes" or "cubes").

    The code I use is:

    import os
    import appuifw

    L = [u"Write File C:", u"Read File C:"]

    test = appuifw.popup_menu(L, u"Select + press OK:")

    if test == 0 :
    f=open("c:\\escritura.txt", 'w');
    f.write(u"Hello World");
    f.close()
    appuifw.note(u"Write Sucsess", "info")
    elif test == 1 :
    f=open("c:\\escritura.txt", 'r')
    test= f.readline()
    f.close()
    appuifw.note(test, "info")

    First option "Write File" is OK but "Read File" always shows a message with "four or five "boxes" or "cubes"". The message should be "Hello World".

    To compile the .sis I use the next code:
    python ensymble.py py2sis --uid=0xE1112223 --appname="Prueba" --shortcaption="App Prueba" --caption="Mi Aplicacion" --version=1.0.0 --caps=NetworkServices+LocalServices+ReadUserData+WriteUserData+UserEnvironment --verbose ejemplo1 ejemplo1

    Can you help me?

    Sorry for my english
    Thanks.

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Read Text not success

    Add (and modify) this to the code:
    import codecs

    f=codecs.open("c:\\escritura.txt", 'w', 'utf_8')

    f=codecs.open("c:\\escritura.txt", 'r', 'utf8')

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    9

    Re: Read Text not success

    It should be easy, if I'm not wrong what you get as output from a file is not in Unicode.
    To unicode a string just type:
    u"Hello"
    or if the string is a variable:
    unicode(file.read())
    Tell us if this works!
    Luke

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    4

    Re: Read Text not success

    OK, thanks....

    two options are so good.

    f=codecs.open("c:\\escritura.txt", 'w', 'utf_8')
    f=codecs.open("c:\\escritura.txt", 'r', 'utf8')
    OK

    unicode(file.read())
    OK

    verified,....THANKS, THANKS....

Similar Threads

  1. Read from a text file
    By razas in forum Symbian
    Replies: 4
    Last Post: 2010-12-06, 05:53
  2. how can read text in the text box
    By Gill in forum Symbian
    Replies: 4
    Last Post: 2008-11-14, 05:50
  3. Read text Line from text File
    By CarusoAlex in forum Symbian
    Replies: 4
    Last Post: 2008-02-06, 12:24
  4. Read text file line by line
    By fdelvalle in forum Symbian
    Replies: 5
    Last Post: 2007-01-31, 09:48
  5. Sending Text over bluetooth
    By Amilael in forum Symbian
    Replies: 1
    Last Post: 2006-08-11, 14:11

Posting Permissions

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