Android Question [Solved] How to save EditText as Unicode?

Discussion in 'Android Questions' started by Beja, Feb 20, 2015.

  1. Beja

    Beja Expert Licensed User

    Arabic text can be displayed correctly on EditText1, but when save it and later load it, it is loaded in Chinese (real Chinese) leters.
    How can one saves it in Unicode?

    Thanks in advance.
     
    Last edited: Feb 20, 2015
  2. KMatle

    KMatle Expert Licensed User

    Beja likes this.
  3. Erel

    Erel Administrator Staff Member Licensed User

    Just use File.WriteString and load it with File.ReadString. It will use UTF8 and it supports all characters.
     
  4. Beja

    Beja Expert Licensed User

    Hi Erel,
    Following is the code.. it's saving, but loadfile is not loading the file 1.txt back to EditText1.text, but
    I can see it directly from the device storage (English correctly but Arabic in Chinese chars).

    Code:
    Sub loadfile
        EditText1.Text = 
    File.ReadString(File.DirRootExternal, "1.txt"
    End Sub
    Sub btnSave_Click
        
    File.WriteString(File.DirRootExternal, "1.txt", EditText1.Text)
    End Sub
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    It can't be Beja. The problem is somewhere else.
    Use a text editor such as Notepad++ to check it. You are probably opening it with an editor that doesn't support UTF8.
     
  6. Beja

    Beja Expert Licensed User

    Thanks and I am using Notpad that comes with Windows 8.1
    will try Notepad ++, I hope it's free ;)
     
  7. Beja

    Beja Expert Licensed User

    You are right Erel,
    I saved it to my PC and opened it from there in MS Word.. it showed the correct original Arabic text.
    Thanks for the hint.
    What's left now it is not loading back to edittext1 as in the above code.
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    If you are unable to solve it then upload a small example that demonstrates the issue.
     
  9. Beja

    Beja Expert Licensed User

    here it is!
     

    Attached Files:

  10. klaus

    klaus Expert Licensed User

    I tested your code with french text with éè and it works.
    Be sure you do a long click to save the file.
    As you have an empty Click event routine, a click on the save button does nothing.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice