[rules-users] question about encoding in rules

João Mota joaoacmota at gmail.com
Wed Mar 12 06:54:46 EDT 2008


Greetings,

I am having some issues with encoding in my rules. I am using a drl like
this:

package pt.xpto.mydroolstest
import pt.xpto.model.SimpleFact
import pt.xpto.model.SimpleResult
import java.util.ArrayList
import java.util.Collection

global Collection results


rule 'first-rule'

when
     SimpleFact(description=="someDescription", value < "500") and
     SimpleFact(description=="anotherDescription", value=="1");

then

    SimpleResult result = new SimpleResult();
    ArrayList aList= new ArrayList();
    result.setDescription("Some String with portuguese chars like ç and à");
    aList.add("Another String with portuguese chars like é and ã.");
    result.setValue(aList);
    results.add(result);
end


My problem is that when i retrieve the results from firing the rules, the
encoding of the strings with the portuguese chars is all messed up. From the
tests i did, this happens when the rules are compiled by drools.

If i make the following modification to the rules

     result.setDescription(new String("Some String with portuguese chars
like ç and à".getBytes(),"utf-8"));

 and load it like this, then the strings are retrieved ok.

        RuleBase ruleBase = RuleBaseLoader.getInstance().loadFromReader(new
InputStreamReader(DroolsTest.class.getResourceAsStream( "Rules.drl" )));

Yet the same modification does not work if the rule is defined in the BRMS
and loaded by the rules agent.


I noticed that in the portuguese example shown in
http://labs.jboss.com/drools/ no portuguese special chars are used, is this
a limitation of the rules engine or am I just using wrong?

Can you point me in the right direction?

best regards,

João Mota
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080312/62112f2a/attachment.html 


More information about the rules-users mailing list