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...

Any pointers welcome!

Regards

Ute
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to