问题
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