Java operator in Genexus

I would like to use the following Java statement in GeneXus, but I don't know the GeneXus syntax for embedded Java code.

str = new String(str.getBytes("8859_1"), "UTF-8");

      

How can i do this?

+3


source to share


3 answers


&str = 'my text'

JAVA [!&str!] = new String([!&str!].getBytes("8859_1"), "UTF8");

      



Documentation link

+5


source


It should have control over exceptions as mentioned below. Without exception, the error java.io.UnsupportedEncodingException will be thrown.



& str = 'text'

JAVA try {[! & str!] = new String ([! & str!]. getBytes ("UTF-8")); } catch (java.io.UnsupportedEncodingException e) {}

0


source


Pair incluir codigo java, necesitas usar la palabra reservada "java" al principio de cada linea. Si en esa linea necesitas joins una variable / atributo de GeneXus, o que esa variable marine available 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 }

      

0


source







All Articles