[daisy] [JIRA] Resolved: (DSY-474) Rich text content doesn't transfer properly through the Java api (extended ascii)

Bruno Dumon (JIRA) issues at cocoondev.org
Wed May 23 13:46:20 CDT 2007


     [ http://issues.cocoondev.org//browse/DSY-474?page=all ]
     
Bruno Dumon resolved DSY-474:
-----------------------------

    Resolution: Invalid

The problem is in your own code: part data are bytes, strings are characters. You need to specify an encoding for the conversion (if the default is not OK). Since Daisy-HTML parts are XML, they are by default UTF-8, so the correct code would be:

String body = new String(part.getData(), "UTF-8"); 

> Rich text content doesn't transfer properly through the Java api (extended ascii)
> ---------------------------------------------------------------------------------
>
>          Key: DSY-474
>          URL: http://issues.cocoondev.org//browse/DSY-474
>      Project: Daisy
>         Type: Bug
>   Components: Repository
>     Versions: 2.0.1
>     Reporter: Mike McLean
>     Priority: Minor

>
> To reproduce:
> 1) Starting from a new document type that includes a SimpleDocumentContent part type, create a new document (in my case, using a French variant) and enter extended ascii characters (i.e.: "Un numéro de carte de crédit"). Save and publish
> 2) From the Java api, get a handle on the part and create a string from the content:
> String body = new String(part.getData());
> OR 
>  
> InputStream in = part.getDataStream();
> StringBuffer out = new StringBuffer();
> byte[] b = new byte[4096];
> for (int n; (n = in.read(b)) != -1;) {
>   out.append(new String(b, 0, n));
> }
> Both strings will yield the following: Un numéro de carte de crédit

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



More information about the daisy mailing list