• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [OT] file encoding - [Solved]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] file encoding - [Solved]


  • Subject: Re: [OT] file encoding - [Solved]
  • From: Ute Hoffmann <email@hidden>
  • Date: Tue, 15 May 2007 23:20:05 +0200

I found the solution. One does not need to change the encoding of the string before saving it with a certain encoding. Saving the string with the encoding one wants directly to the file is sufficient (only step b needed). Sorry for bothering you with this. Thank you for your help.

Chuck, you are right. Hydra guesses wrongly. Also W3C Validator guesses wrongly but now the umlauts are displayed correctly with the wished encoding thus never mind what the validator guesses.


Am Dienstag, 15.05.07 um 20:23 Uhr schrieb Chuck Hill:


On May 15, 2007, at 5:23 AM, Ute Hoffmann wrote:

Hallo,
I need to save a string (text) into a file. The file has to have a specified encoding which differs from the default encoding which is MacRoman.


How can I archive this (probably very easy, but...)

I can create and save the file. But it always ends in a macRoman/MacCentralEurope encoding (no matter what I try)

This is trhe relevant part of my code:

A. Convert String from MacRoman to UTF 8:
try{
String fileInhalt = new String(inhaltsstring.getBytes("MacRoman"), "UTF8");
writeOutput(fileInhalt);
}
catch (Exception e){
NSLog.out.appendln("String Konversion hat nicht geklappt"+e.toString());
}


Works on my string. no error message.

B. Save file in file systhem

public void writeOutput(String str) {

try {
FileOutputStream fos = new FileOutputStream(pfade.zumRootVerzeichnis()+pfade.ordnerPfad()+"/rss/ rss.xml");
Writer out = new OutputStreamWriter(fos, "UTF8");
out.write(str);
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}


The file is saved, but it seems it is not UTF-8 but still MacRoman :-(. When I open it with hydra it says still Mac encoded, not >> UTF-8...

How does Hydra know? Maybe it is a Hydra bug? For Western European languages, the differences between the two is small. Maybe it is just guessing wrongly. The WOResourceManager also has this problem. Try changing it to UTF-16 to see where the problem lies.


Chuck

--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects







_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: [OT] file encoding (From: Chuck Hill <email@hidden>)

  • Prev by Date: Interrupting a fetch that is taking too long
  • Next by Date: auto open URL
  • Previous by thread: Re: [OT] file encoding
  • Next by thread: Re: [OT] file encoding
  • Index(es):
    • Date
    • Thread