|
I have a simple java class that is marshalling a Castor-generated xml
binding class, and am experiencing the loss of the
EURO currency symbol (used in a price display value) during the marshalling. I�m not sure if the problem is the UTF-8 encoding (as opposed to
UTF-16), or something else within Castor that is causing the loss of this
character. As the code snippet below makes plain, the binding class is using a
static Marshaller call, so no special encoding (other
than the default) is being set on the marshaller. Would really appreciate some pointers.
Do I need to edit the Castor-generated binding classes to use a common instance
of a marshaller with the correct encoding set, or (preferable)
is there a way of preserving the character by another means? The relevant classes and code are as follows: ProductReader.java (application
which invokes marshalling behavior) Product.java (castor-generated xml
binding class which defines marshalling behavior) Output.xml (result file generated
from marshalling, encoded in UTF-8) ProductReader { � public
static void readProducts() { ��� Product p = new Product(); ��� ... ��� p.setPriceDisplay("�500�); ��� p.marshal(new FileWriter("Output.xml")); ��� } } Product { � public
void marshal(java.io.Writer out) � ��throws org.exolab.castor.xml.MarshalException, ���������� org.exolab.castor.xml.ValidationException ��� { ������� ������� Marshaller.marshal(this,
out); ��� } //-- void marshal(java.io.Writer) } Output.xml <?xml version="1.0"
encoding="UTF-8"?> . . . <Product> � <Attribute> ��� <DisplayValue>?17.175</DisplayValue> � </Attribute> </Product> . . . Thanks, jonMC |
