Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Java and Win-1251 encoding?

1 view
Skip to first unread message

Thomas Rokamp

unread,
Aug 5, 2003, 7:13:47 AM8/5/03
to
Hi!

I'm testing a russian webpage with HttpUnit, but it seems, that it doesn't
support the encoding (Win-1251).
How can I add support for this in Java or HttpUnit?

java.io.UnsupportedEncodingException: WIN-1251
at sun.io.Converters.getConverterClass(Converters.java:114)
at sun.io.Converters.newConverter(Converters.java:145)
at
sun.io.ByteToCharConverter.getConverter(ByteToCharConverter.java:64)
at java.lang.StringCoding.decode(StringCoding.java:216)
at java.lang.String.<init>(String.java:331)
at java.lang.String.<init>(String.java:359)
at
com.meterware.httpunit.WebResponse.loadResponseText(WebResponse.java:751)
at
com.meterware.httpunit.HttpWebResponse.<init>(HttpWebResponse.java:58)
at
com.meterware.httpunit.WebConversation.newResponse(WebConversation.java:66)
at com.meterware.httpunit.WebClient.getResource(WebClient.java:101)
at com.meterware.httpunit.WebClient.getResponse(WebClient.java:82)
at SubmitTest.testMyTest(SubmitTest.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at junit.textui.TestRunner.run(TestRunner.java:72)
at SubmitTest.main(SubmitTest.java:24)

Lothar Kimmeringer

unread,
Aug 5, 2003, 7:17:35 AM8/5/03
to
On Tue, 5 Aug 2003 13:13:47 +0200, Thomas Rokamp wrote:

> I'm testing a russian webpage with HttpUnit, but it seems, that it doesn't
> support the encoding (Win-1251).

Try Cp1251 instead (that's the offical name).

AFAIK 8859_1 is quite similar to Cp1251, so that should work
anyway.


Regards, Lothar
--
Lothar Kimmeringer E-Mail: spam...@kimmeringer.de
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
questions!

Thomas Rokamp

unread,
Aug 5, 2003, 7:27:21 AM8/5/03
to
> Try Cp1251 instead (that's the offical name).
>
> AFAIK 8859_1 is quite similar to Cp1251, so that should work
> anyway.
>
>

But how? I have no access to change the webpage, so it has to be done in the
HttpUnit program...


Jon A. Cruz

unread,
Aug 5, 2003, 11:52:49 AM8/5/03
to
Thomas Rokamp wrote:
> Hi!
>
> I'm testing a russian webpage with HttpUnit, but it seems, that it doesn't
> support the encoding (Win-1251).
> How can I add support for this in Java or HttpUnit?
>
> java.io.UnsupportedEncodingException: WIN-1251
> at sun.io.Converters.getConverterClass(Converters.java:114)
> at sun.io.Converters.newConverter(Converters.java:145)
> at
> sun.io.ByteToCharConverter.getConverter(ByteToCharConverter.java:64)
> at java.lang.StringCoding.decode(StringCoding.java:216)
> at java.lang.String.<init>(String.java:331)
> at java.lang.String.<init>(String.java:359)


1) Check what Java supports for encodings:

http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html

http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html

http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html

2) Realize that Java is doing exactly what Java should be doing.

3) Look to the authors of the third-party project you are using for
support for said third-party project

3b) Look at the HttpUnit sources yourself to determine how it can be
told to susbstitute the proper "Cp1251" encoding for "WIN-1251".

http://httpunit.sourceforge.net/

Roedy Green

unread,
Aug 11, 2003, 2:44:24 PM8/11/03
to
On Tue, 5 Aug 2003 13:13:47 +0200, "Thomas Rokamp" <nos...@crax.dk>
wrote or quoted :

>I'm testing a russian webpage with HttpUnit, but it seems, that it doesn't
>support the encoding (Win-1251).
>How can I add support for this in Java or HttpUnit?

see http://mindprod.com/jgloss/encoding.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

0 new messages