I did specify the type of result ;) It's a StringBuilder and does indeed 
not support the toString("UTF-8")

What I did now:
    FileOutputStream fos = null;
    byte[] byteResult = Charset.forName("UTF-8").encode(result.toString())
.put(0, (byte) 0xEF)
.put(1, (byte) 0xBB)
.put(2, (byte) 0xBF)
.array();
    fos = new FileOutputStream(file);
    fos.write(byteResult);

This works! It's showing my hebrew and chinese characters correct!

But I still have one issue:
The string result.toString() starts with this data (double quotes 
included): *"Startdate";"Starttime";"Enddate";*
However when the file is created and I open it with either notepad++ or 
excel the first characters are  not show, the file always starts with *
artdate"* .

Any idea how to work around this? I though that maybe it just took the 
first few characters (always 3) after the BOM into account but I added some 
spaces between the BOM (exactly 3) and then it's ok. It's a work-around but 
not really the best I hope...

Kr,

Dirk

Op vrijdag 30 maart 2012 00:38:08 UTC+2 schreef Lew het volgende:
>
> b0b wrote:
>
>> For your code to work you need:
>>
>>     out.write(result.toString("UTF-8));
>>
>
> How do you know that the type of 'result' supports such a method? The OP 
> did not indicate the type of 'result'.
>
> Surely you are aware that 'String' values in Java are always UTF-16?
> <http://docs.oracle.com/javase/7/docs/api/java/lang/String.html>
>
> -- 
> Lew
>
>
>  
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to