4

I tried all possible answers this and this , but it didn't worked for me. Now writing the question.

private String convertValue(String val){
    System.out.println("convert input:" + val);
    String res = "";
    StringTokenizer st = new StringTokenizer(val,",");
    while(st.hasMoreTokens()){
        String token = st.nextToken();
        if (token.matches("([0-9]*)")) {
            char c = (char)Integer.parseInt(token);
            res+=c;
        }else{
            res+=token;
        }
    }
    System.out.println("convert output:" + res);
    return res;
}

When running out of the jboss 7 it gives:

convert input:61,1087,1088,1080,1074,1077,1090
convert output:=привет

Running in the jboss 7 by action:

convert input:61,1087,1088,1080,1074,1077,1090
convert output:=??????

Why it is not working properly?

My standalone.xml:

 <extension module="org.jboss.as.weld"/>
</extensions>

<system-properties>
    <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
    <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>
</system-properties>

added java opts(-Dfile.encoding=UTF-8):

convert input:61,1087,1088,1080,1074,1077,1090
convert output:=–ø—Ä–∏–≤–µ—Ç

EDIT 1: My environment:

Mac OS X Version 10.7.5
JBoss 7.1.1.Final
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)

EDIT 2: Code snippet above working in javax.enterprise.context.RequestScoped back bean controller when pressing button from JSF page.

Community
  • 1
  • 1
Rinat Tainov
  • 1,479
  • 2
  • 19
  • 39

2 Answers2

1

Try to add this in your standalone.conf:

JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"

It worked for me when the direct option for the vm did not work.

skuntsel
  • 11,624
  • 11
  • 44
  • 67
kinaesthesia
  • 703
  • 6
  • 27
1

I don't have a Mac, but related questions show that in your case such a code should work:

private String convertValue(String val){
    System.out.println("convert input:" + val);
    String res = "";
    StringTokenizer st = new StringTokenizer(val,",");
    while(st.hasMoreTokens()){
        String token = st.nextToken();
        if (token.matches("([0-9]*)")) {
            char c = (char)Integer.parseInt(token);
            res+=c;
        }else{
            res+=token;
        }
    }

    PrintStream out = new PrintStream(System.out, true, "UTF-8");
    out.println("convert output:" + res);
    return res;
}
Community
  • 1
  • 1
ShyJ
  • 4,560
  • 1
  • 19
  • 19