Mule ESB Groovy Unicode output issue

江枫思渺然 提交于 2020-01-16 00:42:08

问题


I have this little chain of components in my Mule ESB project:

<set-payload value="Получена заявка ##[sessionVars['ticketID']]" doc:name="Set SMS Text"/>
<scripting:transformer doc:name="Send SMS" ignoreBadInput="true">
    <scripting:script engine="Groovy"><![CDATA[
        new File("/tmp/groovy.out").withWriter { out ->
            out.println message.payload
        }
    ]]></scripting:script>
</scripting:transformer>

When message passes this chain in /tmp/groovy.out I can see "Џолучена заЯвка #4041" instead of expected "Получена заявка #4041" ("Получена заявка" - Russian words), i.e. there is a problem with unicode chars output and there are no problems with ASCII chars.

When I check /tmp/groovy.out with HEX editor I see that all Russain chars has 1-byte lenght (in unicode that must be 2-bytes length), i.e. output of my Groovy component is not unicode.

There is no problem with unicode output to Mule log when I user Echo and Logger components. Also in SMTP component everything is perfect: I successfully receive letters in unicode from Mule.

Can you help me with unicode output to file with Groovy in Mule ESB?


回答1:


Can you try:

new File("/tmp/groovy.out").withWriter( 'UTF-8' ) { out ->


来源:https://stackoverflow.com/questions/19924084/mule-esb-groovy-unicode-output-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!