Skip to Content.
Sympa Menu

mace-opensaml-users - Re: UTF-8 character encoding

Subject: OpenSAML user discussion

List archive

Re: UTF-8 character encoding


Chronological Thread 
  • From: Chad La Joie <>
  • To:
  • Subject: Re: UTF-8 character encoding
  • Date: Wed, 01 Aug 2007 18:37:21 -0400
  • Organization: OIS - Middleware

That's why. When you use the LSSerializer it encodes to the character set of the destination. In this case the Java String class, which is UTF-16 (mostly). There isn't a way you can change this, and you shouldn't try. The string really is UTF-16 encoded.

If you want a different encoding you use the serializer and write to a Writer for which you have specified a different encoding character set.

There are methods on XMLHelper to help with this.

Prasanna Krishna wrote:
----- Sample code for base 64 encoding


private String getBase64SAML(Element authElement) throws Exception {
try {
// Serialize to string
DOMImplementationRegistry registry = DOMImplementationRegistry
.newInstance();
DOMImplementationLS impl = (DOMImplementationLS) registry
.getDOMImplementation("LS");
LSSerializer writer = impl.createLSSerializer();
String str = writer.writeToString(authElement);

str = Base64.encode(str.getBytes());

return str;
} catch (Exception x) {
throw new Exception(x);
}
}


--
Chad La Joie 2052-C Harris Bldg
OIS-Middleware 202.687.0124



Archive powered by MHonArc 2.6.16.

Top of Page