I would like to use the following Java statement in GeneXus, but I don't know GeneXus' syntax for embedded Java code.
str = new String(str.getBytes("8859_1"), "UTF-8");
How can I do it?
I would like to use the following Java statement in GeneXus, but I don't know GeneXus' syntax for embedded Java code.
str = new String(str.getBytes("8859_1"), "UTF-8");
How can I do it?
&str = 'my text'
JAVA [!&str!] = new String([!&str!].getBytes("8859_1"), "UTF8");
It needs Exception control as following.Without exception,java.io.UnsupportedEncodingException error will be appeared.
&str = 'text'
JAVA try { [!&str !] = new String([!&str !].getBytes("UTF-8")); } catch (java.io.UnsupportedEncodingException e) { }
Para incluir codigo java, necesitas usar la palabra reservada "java" al principio de cada linea. Si en esa linea necesitas acceder a una variable/atributo de GeneXus, o que esa variable sea accesible por GeneXus, necesitas rodear el nombre de la variable con [!...!] Asi que tu codigo quedaria:
java try {
java [!&str!] = new String([!&str!].getBytes("8859_1"), "UTF-8");
java } catch (Exception ex) {
...
java }