Connecting Tech Pros Worldwide Forums | Help | Site Map

Java and Win-1251 encoding?

Thomas Rokamp
Guest
 
Posts: n/a
#1: Jul 17 '05
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.jav a:114)
at sun.io.Converters.newConverter(Converters.java:145 )
at
sun.io.ByteToCharConverter.getConverter(ByteToChar Converter.java:64)
at java.lang.StringCoding.decode(StringCoding.java:21 6)
at java.lang.String.<init>(String.java:331)
at java.lang.String.<init>(String.java:359)
at
com.meterware.httpunit.WebResponse.loadResponseTex t(WebResponse.java:751)
at
com.meterware.httpunit.HttpWebResponse.<init>(Http WebResponse.java:58)
at
com.meterware.httpunit.WebConversation.newResponse (WebConversation.java:66)
at com.meterware.httpunit.WebClient.getResource(WebCl ient.java:101)
at com.meterware.httpunit.WebClient.getResponse(WebCl ient.java:82)
at SubmitTest.testMyTest(SubmitTest.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl
..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.ja va: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:2 08)
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)




Paul Gorodyansky
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Java and Win-1251 encoding?


Hi,

"Thomas Rokamp" <nospam@crax.dk> wrote in message news:<3f2f91a7$0$32460$edfadb0f@dread16.news.tele. dk>...[color=blue]
> 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[/color]

There is no such encoding name as "WIN-1251":

- official IANA name used in XML ("encoding=..."),
in HTML and JSP ("charset=...") is
"windows-1251"

- internally in Java code, for example as encoding name parameter
while doing conversion
Unicode Java String <---> non-Unicode Byte Array
it is "Cp1251" - see here:
http://java.sun.com/j2se/1.4.2/docs/...oding.doc.html


--
Regards,
Paul Gorodyansky
"Cyrillic (Russian): instructions for Windows and Internet":
http://ourworld.compuserve.com/homepages/PaulGor/
Closed Thread