Stephan Nagy wrote:
> "Hinrich.Boog" wrote:
>
> > Hi there,
> >
> > I have a question concerning the ECS-html library: When I construct an
><select><option
> > value="test"></select> tag with the constructor
> >
> > new Option("test");
> >
> > and the String I pass contains special characters (e.g. like german 'umlaute'),
>the returned HTML
> > code is not correct, instead the option-tag just ends where the special character
>should occur.
> > Has anybody experience with that or a workaround ?
> >
>
i'm pretty sure that this is the same problem magnus (see the "International
characters in 1.4.1"
thread) was having.
he's got back to me now and says that this (emergency) patch (which i've attached) has
fixed the
problem for him.
> Sadly, I only speak one language so I am ill equiped to answer questions of this
>type, but if you
> send me a code example I'll take a look at it.
if Hinrich.Boog can supply a code example, then great - but if you're really stuck
stephen, i have one
from magnus (i'll forward to the list).
i'm not totally happy with the patch since it's a 'intuitive workaround' rather than
reasoned
workaround. i'd be happier to know why ByteArrayOutputStream mangles international
characters but
StringWriter doesn't. i have a gut feeling that the workaround in the patch might have
some ugly
side-effects or that there will be other problems to do with international characters.
stephen - if you could take a look and see what you think, i'd feel a lot happier.
- robert
Index: src/java/org/apache/ecs/GenericElement.java
===================================================================
RCS file: /home/cvs/jakarta-ecs/src/java/org/apache/ecs/GenericElement.java,v
retrieving revision 1.18
diff -u -r1.18 GenericElement.java
--- src/java/org/apache/ecs/GenericElement.java 2000/11/22 00:13:57 1.18
+++ src/java/org/apache/ecs/GenericElement.java 2001/04/03 22:58:16
@@ -52,6 +52,8 @@
*/
package org.apache.ecs;
+import java.io.Writer;
+import java.io.StringWriter;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.BufferedOutputStream;
@@ -715,27 +717,23 @@
*/
public final String toString()
{
- String out = null;
- try
+ System.out.println("TEST toString()");
+ StringWriter write = new StringWriter();
+ String out = null;
+ try
{
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- BufferedOutputStream bos = new BufferedOutputStream(baos);
- output(bos);
- bos.flush();
-
- if ( getCodeSet() != null )
- {
- out = baos.toString(getCodeSet());
- } else
- {
- out = baos.toString();
- }
-
- bos.close();
- baos.close();
+ output(write);
+ write.flush();
+ out = write.toString();
+ write.close();
+ }
+ catch (UnsupportedEncodingException use)
+ {
+ use.printStackTrace();
}
catch (IOException ioe)
{
+ ioe.printStackTrace();
}
return(out);
}
@@ -821,6 +819,14 @@
if (getNeedClosingTag())
out.write(createEndTag());
+ }
+
+ /**
+ Writer version of this method.
+ */
+ public void output(Writer out)
+ {
+ output ( new PrintWriter(out) );
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]