• 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
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] file encoding


  • Subject: Re: [OT] file encoding
  • From: Chuck Hill <email@hidden>
  • Date: Tue, 15 May 2007 11:23:30 -0700


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


  • Follow-Ups:
    • Re: [OT] file encoding - [Solved]
      • From: Ute Hoffmann <email@hidden>
References: 
 >[OT] file encoding (From: Ute Hoffmann <email@hidden>)

  • Prev by Date: Poor Oracle performance?
  • Next by Date: Re: how to do a product->product-type->product-attributes with non pre-determined product-attributes?
  • Previous by thread: [OT] file encoding
  • Next by thread: Re: [OT] file encoding - [Solved]
  • Index(es):
    • Date
    • Thread