Am 15.05.2007 um 14:23 schrieb Ute Hoffmann:

String fileInhalt = new String(inhaltsstring.getBytes("MacRoman"), "UTF8");

This is wrong :)

You generate a byte[] containing a MacRoman byte-rep of the String.
Then you create a String from that, telling the String that the byte [] contains UFT8...
This should generate garbage. Did you test it with Umlauts and sz?

Here is my code to generate an utf-8 NSData. You could push that to a file instead.

static byte utf8Header[] = new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF };
try
{
        byte aByteContent[] = aString.getBytes("UTF-8");
byte aFinalContent[] = new byte[utf8Header.length + aByteContent.length];
        System.arraycopy(utf8Header, 0, aFinalContent, 0, utf8Header.length);
System.arraycopy(aByteContent, 0, aFinalContent, utf8Header.length, aByteContent.length);
        this.setDocumentData(new NSData(aFinalContent));
}
catch (UnsupportedEncodingException e)
{
        e.printStackTrace();
}

Gruß,
        atze


_______________________________________________
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