Android Question Spanish Characters in Filename -- FileNotFoundException

Discussion in 'Android Questions' started by Sterling, May 15, 2015.

  1. Sterling

    Sterling New Member Licensed User

    Hey all --

    I'm working with retrieving data from files, some having distinctive Spanish characters or accented vowels in the filenames (e.g. enseñar.txt, marrón.txt, but also libro.txt).

    Working: When I open up libro.txt, I have no issues. There are no distinctive Spanish characters or accented vowels in the filename. The file opens with no problem, and all Spanish text looks great. Again, the problem isn't the file *contents* -- I have that working when the file reads.

    Not Working: When I try to open up enseñar.txt using a TextReader and File.OpenInput command, or any other filename with a distinctive Spanish character or accented vowel, I run into a FileNotFoundException (java.io.FileNotFoundException: enseñar.txt).

    Any way around this, or should I come up with a standardized workaround with English filenames?

    Code:
    ' [ Unit Test: Filenames with ñ ]
    Dim strTerm As String = "enseñar"
    ' Preferred Method: Load in strTerm from File
    Dim strTermInfo As String = ""

    Dim trSpanish As TextReader
    trSpanish.Initialize2(
    File.OpenInput(File.DirInternal & "/terms/", strTerm.ToLowerCase & ".txt"), "iso-8859-1")
    strTermInfo = trSpanish.ReadAll
    trSpanish.Close
    (Also a follow-up to this -- if I read values such as enseñar from a file encoded with page iso-8859-1, would I need to run a convert on it to UTF-8 in order to interface with the file system? I'm thinking it could be an encoding mismatch with the file system.)
     
    Last edited: May 15, 2015
  2. Sterling

    Sterling New Member Licensed User

    Fixed!

    Ok, for a filename to interface properly, it has to be in UTF-8 encoding. In reading values from iso-8859-1 and passing that through, it's assigning special characters differently. Reading in as UTF-8 for the filename only, while reading in the contents as iso-8859-1 worked.
     
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