> Reading the encoding from the XML file requires the template to be read and> > parsed twice. Is it worth? I think it's not as most of users are perfectly> > fine with using utf8.
Actually, just have to read the first line. If it's a valid xml file the first line will be the <?xml >. http://xmlwriter.net/xml_guide/xml_declaration.shtml We could read the first line directly from the InputStream without the LineNumberReader. If it's wrapped in a BufferedInputStream then we can mark and reset in the case it's not the xml declaration. Even opening the file twice isn't going to be that big of a hit, it should rarely happen. It's important because it's the right thing to do considering that we have users in China that might be using charsets other than UTF-8. On Mon, Jan 9, 2012 at 12:51 PM, Igor Drobiazko <[email protected]> wrote: > On Fri, Jan 6, 2012 at 10:16 PM, Josh Canfield <[email protected]>wrote: > >> I believe you want to define UTF8 for both the reader and the writer. >> > > Good catch. Thank you. Will fix that. > >> >> Setting the file.encoding only masks the real problem of not fully >> supporting XML for templates. >> > > Reading the encoding from the XML file requires the template to be read and > parsed twice. Is it worth? I think it's not as most of users are perfectly > fine with using utf8. > > >> >> On Fri, Jan 6, 2012 at 4:39 AM, <[email protected]> wrote: >> > Author: drobiazko >> > Date: Fri Jan 6 12:39:58 2012 >> > New Revision: 1228156 >> > >> > URL: http://svn.apache.org/viewvc?rev=1228156&view=rev >> > Log: >> > TAP5-1741: Using UTF8 for template's input stream >> > >> > Modified: >> > tapestry/tapestry5/trunk/build.gradle >> > >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/XMLTokenStream.java >> > >> > Modified: tapestry/tapestry5/trunk/build.gradle >> > URL: >> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/build.gradle?rev=1228156&r1=1228155&r2=1228156&view=diff >> > >> ============================================================================== >> > --- tapestry/tapestry5/trunk/build.gradle (original) >> > +++ tapestry/tapestry5/trunk/build.gradle Fri Jan 6 12:39:58 2012 >> > @@ -97,7 +97,7 @@ subprojects { >> > >> > systemProperties["tapestry.service-reloading-enabled"] = "false" >> > >> > - jvmArgs("-XX:MaxPermSize=512m") >> > + jvmArgs("-XX:MaxPermSize=512m", "-Dfile.encoding=UTF-8") >> > } >> > >> > task sourcesJar(type: Jar, dependsOn: classes) { >> > >> > Modified: >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/XMLTokenStream.java >> > URL: >> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/XMLTokenStream.java?rev=1228156&r1=1228155&r2=1228156&view=diff >> > >> ============================================================================== >> > --- >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/XMLTokenStream.java >> (original) >> > +++ >> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/XMLTokenStream.java >> Fri Jan 6 12:39:58 2012 >> > @@ -334,7 +334,7 @@ public class XMLTokenStream >> > { >> > InputStream rawStream = resource.openStream(); >> > >> > - InputStreamReader rawReader = new InputStreamReader(rawStream); >> > + InputStreamReader rawReader = new InputStreamReader(rawStream, >> "UTF8"); >> > LineNumberReader reader = new LineNumberReader(rawReader); >> > >> > ByteArrayOutputStream bos = new ByteArrayOutputStream(5000); >> > >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > > -- > Best regards, > > Igor Drobiazko > http://tapestry5.de > http://twitter.com/drobiazko --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
