Re: Reading and writing files character encoding
Hendrik Schreiber <hs-doAduxQln/dWk0Htik3J/[email protected]>
| Newsgroups | gmane.org.user-groups.trijug.juglist |
|---|---|
| Message-ID | <[email protected]> |
Tony, if you are just dumping the text to a file, use streams, not reader/ writers. That way you do not decode and encode the text. If you need to access the actual text, you will have to find out the character encoding (either in the HTP content-type header or the first line of the XML file), then use an InpuStreamReader with the charset specified. To write, you will need to use an OutputStreamWriter with the charset specified. AFAIR FileWriter unfortunately does not let you specify the charset and is therefore fairly useless. -hendrik On Jan 7, 2007, at 17:55 , Tony Spencer wrote: > Hi, > I am attempting to read a simple XML feed over HTTP and write it to > my local disk. The feed has some spanish in it so there are non-US > characters present. Currently I use a BufferedReader and > InputStream to read the feed and I write it to disk with > FileWriter. The problem is that the non-US characters (such as the > second character in this provice http://en.wikipedia.org/wiki/ > Malaga) are mangled in the local copy that is written. > > Can someone explain how to deal with different character encodings > in cases such as this? Do you need to know the encoding of the > content you are receiving? > > Thanks, > Tony > _______________________________________________ > Juglist mailing list > [email protected] > http://trijug.org/mailman/listinfo/juglist_trijug.org