• 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: Alexander Spohr <email@hidden>
  • Date: Wed, 16 May 2007 10:54:13 +0200


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@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >[OT] file encoding (From: Ute Hoffmann <email@hidden>)

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