Hello,

  I'm having difficulty creating files using Camel 2.8.0 that use the Euro
character '€' and the registered trademark character '®'.  I've tried to set
the encoding on the file URI to UTF-8, as well as on the Exchange via the
property Exchange.CHARSET_NAME and each time the output data file is
incorrect.  

  I've included a Camel test case below that demonstrates the issue.  When
printing the string via Java, everything works properly.  When writing to
the file, the content does not match the input string.

  Could someone advise me as the best way to properly output the UTF-8
character set via Camel?  Thanks!

Phil

====

/**
 * 
 */
package com.bglobal.etf.dixie.camel;

import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
import org.junit.Test;

/**
 * Apache Camel test case for UTF-8 characters
 * A test file will be written to file:://c/tmp after this runs
 * I'm expecting the text in the file to match that of the testString
 * @author Philip Glebow
 * 
 */
public class CamelEncodingTest extends CamelTestSupport {

        private Log log = LogFactory.getLog(CamelEncodingTest.class);

        private String testString = "€ euro symbol, ® registered trade mark
symbol";

        private String fromURI = "direct:in";

        private String toURI = "file://c:/tmp?charset=utf-8";

        @Test
        public void test() {
                try {                   
                        log.info(testString);
                        template.sendBodyAndProperty(fromURI, testString, 
Exchange.CHARSET_NAME,
"utf-8");
                } catch (Exception e) {
                        log.error(e.getMessage(), e);
                        Assert.fail(e.getMessage());
                }
        }

        @Override
        protected RouteBuilder createRouteBuilder() throws Exception {
                return new RouteBuilder() {

                        @Override
                        public void configure() throws Exception {
                                from(fromURI).to(toURI);
                        }
                };
        }

}
=====

--
View this message in context: 
http://camel.465427.n5.nabble.com/UTF-8-and-Files-Created-by-Camel-tp5053652p5053652.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to