• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Problems with encoding and files

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends pls some help my problems is the following

I have a ftp server running on linux and in my program I download files from the ftp server using class specified below.When I download the file content not all content is coming ok. For example I have a string with
Ra�l����1234%#=?[a_@ and when I read content using my methods this part is retirved ok Ra and this one is retrived wrong �����
whith characteres very stranges.

I suppose that the problem is with the encoding, then all day I tried some settings in the class new InputStreamReader.First the encoding UTF-8 because I have created the file using this encoding. Something like this:

in = new InputStreamReader(new GZIPInputStream(localFtp.get(serverFile)),"UTF-8");

but does not work

After I realized that I use the statement localFtp.ascii();
declaring that the content will be downloaded in ascii encoding so
I made this change :

in = new InputStreamReader(new GZIPInputStream(localFtp.get(serverFile)),"US-ASCII");

but still does not work

Please somebody can help me this is very urgent

Here is my code

Tkx

 
Mercurio Savedra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot this





Tkx
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To make sure I understand your problem correctly:
Your string should be received as: "Ra�l����1234%#=?[a_@"
Your string is received as Ra+jibber
Correct?
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Surely, if you've downloaded a non-ASCII file using ASCII encoding, you've already broken it. So it doesn't matter what encoding you use for reading after downloading it - you may be unable to fix it, because information may have been lost/corrupted. Trying to use "US-ASCII" for reading is never going to give good values for non-ASCII characters.

Shouldn't you download the file in binary?
 
reply
    Bookmark Topic Watch Topic
  • New Topic