I was able to produce similar results in bsh and then I started to get things 
working, so perhaps this will provide some insight...
bsh % baos = new ByteArrayOutputStream();
bsh % baos.write(new byte[] {0xCE,0xA4,0xCE,0xAD,0xCF,0x82,0xCF,0x84}, 0, 8);
bsh % print(baos.toString("UTF-8"));
Τέςτ

I picked some characters from charmap, pasted them into Notepad++, then 
switched to hex mode to get the codes.
From: [email protected]
Date: Tue, 18 May 2010 18:14:38 -0700
To: [email protected]
Subject: [castor-user] Marshaller not properly encoding to UTF-8

Hi,
Im having a problem with my castor Marshaller. Check this example:



//Just For testing, this is not production codePerson p = (Person) object;

PrintStream ps = new PrintStream(System.out, true, "UTF-8");
//This line prints the UTF-8 characters correctly :)ps.println(p.getFullName());



//The actual code that has the problem//PrintWriter that wraps the SAME Stream 
used aboveByteArrayOutputStream baos = new ByteArrayOutputStream();      

PrintWriter writer = new PrintWriter(new PrintStream(baos, true, 
"UTF-8"));marshaller.setSuppressXSIType(true);marshaller.marshal(object,writer);
//This line prints (?) instead of the UTF-8 characters :(

return baos.toString();
Any idea what I'm doing wrong? Please any help will be appreciated.
--Pablo                                           
_________________________________________________________________
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1

Reply via email to