[ 
https://jira.codehaus.org/browse/DISPL-471?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=287814#comment-287814
 ] 

Michael Osipov commented on DISPL-471:
--------------------------------------

I have found the error which is responsible for the incorrect encoding and 
patched it: DISPL-674.
My CSV export works as desired now.
                
> Patch to allow displaytag users to specify the target encoding of export files
> ------------------------------------------------------------------------------
>
>                 Key: DISPL-471
>                 URL: https://jira.codehaus.org/browse/DISPL-471
>             Project: DisplayTag
>          Issue Type: New Feature
>          Components: Export
>            Reporter: Frantz DEGRIGNY
>   Original Estimate: 30 minutes
>  Remaining Estimate: 30 minutes
>
> It will be very useful to permit to the displaytag users to choose for the 
> export files a different encoding than the JSP page.
> This will solve many national characters problems (as MS Excel cannot read 
> UTF-8 encoded files, for example).
> This can be simply done with an ExportDelegate little patch which permits the 
> user to specify the traget encoding in the getMimeType() method of a custom 
> ExportView implementation. :
> example :
> public class ExcelCsvView extends CsvView {
>       public String getMimeType() {
>               return "text/csv; charset=cp1252"; //uses the Windows Latin-1 
> superset encoding
>       }
> }
> ExportDelegate patch :
> --- ExportDelegate.java
> +++ ExportDelegate.java
> @@ -112,124 +112,131 @@
>          String characterEncoding = wrapper.getCharacterEncoding();
>          String wrappedContentType = wrapper.getContentType();
>  
>          if (wrappedContentType != null && 
> wrappedContentType.indexOf("charset") > -1)
>          {
>               // charset is already specified (see #921811)
>               characterEncoding = 
> StringUtils.substringAfter(wrappedContentType, "charset=");
>          }
>  
> +        //the target encoding is already specified in contentType :
> +        if( contentType.indexOf("charset") > -1) 
> +        {
> +             characterEncoding=StringUtils.substringAfter(contentType, 
> "charset=");
> +             contentType = contentType.substring(0, 
> contentType.indexOf(';')).trim();
> +        }
> +
>          if (characterEncoding != null && contentType.indexOf("charset") == 
> -1) //$NON-NLS-1$
>          {
>              contentType += "; charset=" + characterEncoding; //$NON-NLS-1$
>          }
> A better solution (but a little more complicated) is to allow the encoding 
> specification with a taglib table property like this :
> <display:setProperty name="export.csv.encoding" value="cp1252"/> (But I 
> haven't found how to do this).
> Frantz D.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
displaytag-devel mailing list
displaytag-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-devel

Reply via email to