You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Simon Bergweiler (JIRA)" <ax...@ws.apache.org> on 2005/11/10 17:49:04 UTC

[jira] Created: (AXIS-2297) UTF-8 support for attachments (text/plain)

UTF-8 support for attachments (text/plain)
------------------------------------------

         Key: AXIS-2297
         URL: http://issues.apache.org/jira/browse/AXIS-2297
     Project: Apache Axis
        Type: Bug
  Components: Serialization/Deserialization  
    Versions: 1.3    
 Environment: Suse Linux 9.2, 
Java sdk 1.5,


    Reporter: Simon Bergweiler


I tried to send UTF-8 encoded data as String in my attachment.
So I used the MIME type "text/plain". But after the deserialization process
the characters looked like this ( --> ü ü ü ü. ).

This is a conversion problem of the DataHandler class and the getContent() 
function.  

The Problem is placed in the class PlainTextDataHandlerDeserializer.

I fixed my UTF-8 problem as follows

into the function startElement()

public void startElement(String namespace, 
String localName,
                             String prefix, Attributes attributes,
                             DeserializationContext context)
        throws SAXException {

...
    //******before********
    //setValue(dh.getContent());


    // my HACK
    Object ob = dh.getContent();
        if (ob instanceof String) {
	    java.io.InputStream inStream =dh.getInputStream();

	    StringBuffer contents = new StringBuffer();
	    BufferedReader input = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
	    String line = null;
	    while ((line = input.readLine()) != null) {
		contents.append(line);
		contents.append(System.getProperty("line.separator"));
	    }
	    setValue(contents.toString());
	} else {
	    setValue(ob);
	}// end of my HACK
}


I hope that helps.

-best regs,
Simon


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira