Can't get correct content when the encoding of template is UTF-8,GBK --------------------------------------------------------------------
Key: XDT-1671 URL: http://opensource.atlassian.com/projects/xdoclet/browse/XDT-1671 Project: XDoclet Type: Bug Components: XDoclet Module Versions: 1.2.3 Environment: windows xp, jdk5.0, eclipse 3.2 Reporter: nowind Assigned to: xdoclet-devel (Use for new issues) the ant script is: <target name="test"> <taskdef name="doclet" classname="xdoclet.DocletTask" classpathref="path.libAndClasses" /> <doclet destdir="${dir.generated}/test" verbose="true"> <fileset dir="${dir.domain}"> <include name="domain/*.java" /> </fileset> <template templateFile="resources/test.xdt" destinationFile="{0}.java" subTaskName="Create Controller file(s).." /> </doclet> </target> When the encoding of the template file is UTF-8(or other Chinese encoding like GBK), and it contains some Chinese Characters, the files it generated will have some strange and unidentifiable characters. But the unidentifiable characters are just a little part of the Chinese characters, most are correct. the bug is in the function "getURLContent " of FileManager class. try { InputStream is = null; if ("file".equals(url.getProtocol())) { is = new java.io.FileInputStream(url.getFile()); } else { is = url.openStream(); } ByteArrayOutputStream baos = new ByteArrayOutputStream(is.available()); pump(is, baos); content = new String(baos.toByteArray()); urlCache.put(url, content); return content; } we must specify the encoding of the url content. for example, if the encoding is UTF-8, we need to use: new InputStreamReader(is,"UTF-8") to get the correct content. and, we must specify the encoding to get the content BEFORE we use the function "pump" to copy the content to a outstream. If we copy them before we specify the encoding, we will get some unidentifiable characters. and, we need to add getDocEncoding and setDocEncoding method to TemplateSubTask, and specify it in ant script. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/xdoclet/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ xdoclet-devel mailing list xdoclet-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-devel