You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by jian chen <ch...@gmail.com> on 2005/05/02 20:36:45 UTC

byte order mark and InputStreamReader problem

Hi, 

I created a template in UTF8 encoding on my windows machine. When I
rendered it on the web, the browser connected to the server fine but
then it waited infinitely.

I then modified the problematic template and got rid of the byte order
mark (BOM) at the very beginning of the template. This time, the page
loaded  successfully in the browser.

What I am getting at is, Velocity uses java.io.InputStreamReader, and
given UTF8 encoding, the InputStreamReader does not handle the byte
order mark.

I also read somewhere that this problem of not able to handle BOM  has
been a long standing bug with JDK implementation.

Now, just want to know you guys idea if Velocity should be hacked to
use a custom-made InputStreamReader that could open the file, detect
the encoding, and discard the byte order mark, if applicable.

Any thoughts?

Thanks,

Jian

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: byte order mark and InputStreamReader problem

Posted by jian chen <ch...@gmail.com>.
Hi, 

To further the question, one class I found might be useful for this:

http://xml.apache.org/xerces2-j/javadocs/xerces2/org/apache/xerces/xinclude/XIncludeTextReader.html

It has a method called consumeBOM(java.io.InputStream stream,
java.lang.String encoding)

Cheers,

Jian

On 5/2/05, jian chen <ch...@gmail.com> wrote:
> Hi,
> 
> I created a template in UTF8 encoding on my windows machine. When I
> rendered it on the web, the browser connected to the server fine but
> then it waited infinitely.
> 
> I then modified the problematic template and got rid of the byte order
> mark (BOM) at the very beginning of the template. This time, the page
> loaded  successfully in the browser.
> 
> What I am getting at is, Velocity uses java.io.InputStreamReader, and
> given UTF8 encoding, the InputStreamReader does not handle the byte
> order mark.
> 
> I also read somewhere that this problem of not able to handle BOM  has
> been a long standing bug with JDK implementation.
> 
> Now, just want to know you guys idea if Velocity should be hacked to
> use a custom-made InputStreamReader that could open the file, detect
> the encoding, and discard the byte order mark, if applicable.
> 
> Any thoughts?
> 
> Thanks,
> 
> Jian
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: byte order mark and InputStreamReader problem

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi,

> It is bad that SUN never bothers to fix the InputStreamReader BOM issue.

Everybody interested, let's vote for it.  ;)
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058

Best regards,
-- Shinobu

--
Shinobu Kawai <sh...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: byte order mark and InputStreamReader problem

Posted by Daniel Dekany <dd...@freemail.hu>.
Tuesday, May 3, 2005, 12:51:13 AM, jian chen wrote:

> Thanks Shinobu, that is exactly what I want.
>
> It is bad that SUN never bothers to fix the InputStreamReader BOM issue.

What is causing the "browser connected to the server fine but then it
waited infinitely" phenomena? Where can things hang up or go into
infinite loop here? The worst that I could imagine is a question mark at
the beginning of the HTML document if you are using ISO-8859-x and other
restricted charsets for the HTTP response.

> Cheers,
>
> Jian
>
> On 5/2/05, Shinobu Kawai <sh...@gmail.com> wrote:
>> Hi Jian,
>> 
>> > I created a template in UTF8 encoding on my windows machine. When I
>> > rendered it on the web, the browser connected to the server fine but
>> > then it waited infinitely.
>> >
>> > I then modified the problematic template and got rid of the byte order
>> > mark (BOM) at the very beginning of the template. This time, the page
>> > loaded  successfully in the browser.
>> >
>> > What I am getting at is, Velocity uses java.io.InputStreamReader, and
>> > given UTF8 encoding, the InputStreamReader does not handle the byte
>> > order mark.
>> >
>> > I also read somewhere that this problem of not able to handle BOM  has
>> > been a long standing bug with JDK implementation.
>> >
>> > Now, just want to know you guys idea if Velocity should be hacked to
>> > use a custom-made InputStreamReader that could open the file, detect
>> > the encoding, and discard the byte order mark, if applicable.
[snip]

-- 
Best regards,
 Daniel Dekany


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: byte order mark and InputStreamReader problem

Posted by jian chen <ch...@gmail.com>.
Thanks Shinobu, that is exactly what I want.

It is bad that SUN never bothers to fix the InputStreamReader BOM issue. 

Cheers,

Jian

On 5/2/05, Shinobu Kawai <sh...@gmail.com> wrote:
> Hi Jian,
> 
> > I created a template in UTF8 encoding on my windows machine. When I
> > rendered it on the web, the browser connected to the server fine but
> > then it waited infinitely.
> >
> > I then modified the problematic template and got rid of the byte order
> > mark (BOM) at the very beginning of the template. This time, the page
> > loaded  successfully in the browser.
> >
> > What I am getting at is, Velocity uses java.io.InputStreamReader, and
> > given UTF8 encoding, the InputStreamReader does not handle the byte
> > order mark.
> >
> > I also read somewhere that this problem of not able to handle BOM  has
> > been a long standing bug with JDK implementation.
> >
> > Now, just want to know you guys idea if Velocity should be hacked to
> > use a custom-made InputStreamReader that could open the file, detect
> > the encoding, and discard the byte order mark, if applicable.
> 
> Currently, there's a ResourceLoader which handles this issue up on bugzilla.
>     http://issues.apache.org/bugzilla/show_bug.cgi?id=21582
> 
> Best regards,
> -- Shinobu
> 
> --
> Shinobu Kawai <sh...@gmail.com>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: byte order mark and InputStreamReader problem

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Jian,

> I created a template in UTF8 encoding on my windows machine. When I
> rendered it on the web, the browser connected to the server fine but
> then it waited infinitely.
> 
> I then modified the problematic template and got rid of the byte order
> mark (BOM) at the very beginning of the template. This time, the page
> loaded  successfully in the browser.
> 
> What I am getting at is, Velocity uses java.io.InputStreamReader, and
> given UTF8 encoding, the InputStreamReader does not handle the byte
> order mark.
> 
> I also read somewhere that this problem of not able to handle BOM  has
> been a long standing bug with JDK implementation.
> 
> Now, just want to know you guys idea if Velocity should be hacked to
> use a custom-made InputStreamReader that could open the file, detect
> the encoding, and discard the byte order mark, if applicable.

Currently, there's a ResourceLoader which handles this issue up on bugzilla.
    http://issues.apache.org/bugzilla/show_bug.cgi?id=21582

Best regards,
-- Shinobu

--
Shinobu Kawai <sh...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org