You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by MORÁVEK Peter <mo...@pobox.sk> on 2000/03/14 10:52:39 UTC
Encoding problems
COFIGURATION:
WinNT 4.0, Apache 1.3.9, JServ 1.1, Java 1.2.2,
Cocoon 1.7, Xalan 0.20.0, Xerces 1.0.2
Hello,
I haveproblems with encodings. I use ISO-8859-2 to support
Slovak Characters in my html (through xml->xslt->html) output.
Input is read from a file with ISO-8859-2 characters,
but the only response I receive in html for some characters
is th question character (?).
I've looked through the source code for Cocoon and I've found
this in the org.apache.cocoon.producer.ProducerFromFile class:
public Reader getStream(HttpServletRequest request) throws IOException {
File file = new File(Utils.getBasename(request, this.context));
this.monitor.watch(Utils.encode(request), file);
return new InputStreamReader(new FileInputStream(file)); // <-- WRONG
}
I think, there should be:
return new InputStreamReader(new FileInputStream(file),
encoding); // <-- CORRECT
So I can anywhere in cocoon.properties set the encoding for the
input stream.
Any suggestions ?
Thanx
Peter Moravek
Re: Encoding problems
Posted by Stefano Mazzocchi <st...@apache.org>.
MORÁVEK Peter wrote:
>
> COFIGURATION:
> WinNT 4.0, Apache 1.3.9, JServ 1.1, Java 1.2.2,
> Cocoon 1.7, Xalan 0.20.0, Xerces 1.0.2
>
> Hello,
>
> I haveproblems with encodings. I use ISO-8859-2 to support
> Slovak Characters in my html (through xml->xslt->html) output.
> Input is read from a file with ISO-8859-2 characters,
> but the only response I receive in html for some characters
> is th question character (?).
>
> I've looked through the source code for Cocoon and I've found
> this in the org.apache.cocoon.producer.ProducerFromFile class:
>
>
> public Reader getStream(HttpServletRequest request) throws IOException {
> File file = new File(Utils.getBasename(request, this.context));
> this.monitor.watch(Utils.encode(request), file);
> return new InputStreamReader(new FileInputStream(file)); // <-- WRONG
> }
>
> I think, there should be:
>
> return new InputStreamReader(new FileInputStream(file),
> encoding); // <-- CORRECT
>
> So I can anywhere in cocoon.properties set the encoding for the
> input stream.
>
> Any suggestions ?
This is already planned for Cocoon2.
Pier, make sure you are encoding-safe in the URL generator.
--
Stefano Mazzocchi One must still have chaos in oneself to be
able to give birth to a dancing star.
<st...@apache.org> Friedrich Nietzsche
--------------------------------------------------------------------
Come to the first official Apache Software Foundation Conference!
------------------------- http://ApacheCon.Com ---------------------
Re: Encoding problems
Posted by Stefano Mazzocchi <st...@apache.org>.
MORÁVEK Peter wrote:
>
> COFIGURATION:
> WinNT 4.0, Apache 1.3.9, JServ 1.1, Java 1.2.2,
> Cocoon 1.7, Xalan 0.20.0, Xerces 1.0.2
>
> Hello,
>
> I haveproblems with encodings. I use ISO-8859-2 to support
> Slovak Characters in my html (through xml->xslt->html) output.
> Input is read from a file with ISO-8859-2 characters,
> but the only response I receive in html for some characters
> is th question character (?).
>
> I've looked through the source code for Cocoon and I've found
> this in the org.apache.cocoon.producer.ProducerFromFile class:
>
>
> public Reader getStream(HttpServletRequest request) throws IOException {
> File file = new File(Utils.getBasename(request, this.context));
> this.monitor.watch(Utils.encode(request), file);
> return new InputStreamReader(new FileInputStream(file)); // <-- WRONG
> }
>
> I think, there should be:
>
> return new InputStreamReader(new FileInputStream(file),
> encoding); // <-- CORRECT
>
> So I can anywhere in cocoon.properties set the encoding for the
> input stream.
>
> Any suggestions ?
This is already planned for Cocoon2.
Pier, make sure you are encoding-safe in the URL generator.
--
Stefano Mazzocchi One must still have chaos in oneself to be
able to give birth to a dancing star.
<st...@apache.org> Friedrich Nietzsche
--------------------------------------------------------------------
Come to the first official Apache Software Foundation Conference!
------------------------- http://ApacheCon.Com ---------------------
Re: Encoding problems
Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 14 Mar 2000, [iso-8859-2] MOR�VEK Peter wrote:
> I haveproblems with encodings. I use ISO-8859-2 to support
> Slovak Characters in my html (through xml->xslt->html) output.
> Input is read from a file with ISO-8859-2 characters,
> but the only response I receive in html for some characters
> is th question character (?).
>
> I've looked through the source code for Cocoon and I've found
> this in the org.apache.cocoon.producer.ProducerFromFile class:
>
>
> public Reader getStream(HttpServletRequest request) throws IOException {
> File file = new File(Utils.getBasename(request, this.context));
> this.monitor.watch(Utils.encode(request), file);
> return new InputStreamReader(new FileInputStream(file)); // <-- WRONG
> }
>
> I think, there should be:
>
> return new InputStreamReader(new FileInputStream(file),
> encoding); // <-- CORRECT
>
> So I can anywhere in cocoon.properties set the encoding for the
> input stream.
This would work, but then you're setting the encoding globally for all XML
files. I'm _not_ an i18n expert, but I reckon that a better solution would
be to read the encoding from the XML source file and use that for the
encoding of the output. Maybe Pier has some thoughts on this though.
- donald