Search code examples
javaxmlparsinglocale

Xml parsing not working with Swedish Chrs


I am trying to parse the following xml to punycode but it's not working (i have tried setting the encoding differently).

<?xml version="1.0" encoding="ISO-8859-1" ?>
<domain index="1" domainname="teståbel.nu">

<?xml version="1.0" encoding="UTF-8" ?>
<domain index="1" domainname="teståbel.nu">


public void setDomainName(String domainName) {
        this.domainName = java.net.IDN.toUnicode(domainName);

When I run the setDomain() everything is set correctly.

I have run this on my machine, Windows 7 with Local set to Swedish, and it fails. Then I tested it on another machine with windows XP with Local set to English(US) set to and it Works.

So my conlusion is that the coding is working but my environment is wrong, anyone know how to fix this? Can i run my JVM with some parameter or something?


Solution

  • Okej so I found the answer, I need to run my JVM with he following option:

    JAVA_TOOL_OPTIONS : -Dfile.encoding=UTF8