Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1060

Apache Camel, RabbitMQ, special character is transforrmed into a Question Mark

$
0
0

have a string "X°XX" which RabbitMQ writes out as "X?XX"

I understand that this happens, when you stream a string into bytes with one charset UTF-8.And write the bytes back to a string using another charset such as US_ASCII.

I am using Camel to set up the message and route

from(requestUrl)        .routeId(JourneyConstants.BACKEND_ROUTE_ID)        .routeProperty(CommonConstants.ROUTE_TYPE, RouteIdGenerator.RouteType.AMQP_CONSUMER.name())        .log(JourneyConstants.BACKEND_ROUTE_ID +" Received, payload ${body} and headers, ${headers}")        .removeHeader(JourneyConstants.CONTENT_LENGTH) // Due to a new ISTIO we had to remove the content length header        .setExchangePattern(ExchangePattern.InOnly)        .setHeader(CommonConstants.JOURNEY_NAME, constant(JourneyConstants.JOURNEY_NAME_VALUE))        .setHeader(Exchange.CONTENT_TYPE, constant("application/json;charset=utf-8"))        .convertBodyTo(String.class)        .setProperty(CommonConstants.ORIGINAL_MESSAGE, body())        .setProperty(CommonConstants.BACKEND_URL, constant(backendUrl))        .setProperty(CommonConstants.FAILURE_QUEUE_URL, constant(queueUrls))        .setProperty(CommonConstants.CODES_TRANSIENT_QUEUE, constant("50[0-9]|40[1,3,4,8]"))        .setProperty(CommonConstants.CODES_PERSISTENT_QUEUE, constant("4[0,2,5,6,7,9]"))        .convertBodyTo(String.class)        .setHeader(CommonConstants.USE_HEADER_STRATEGY,constant("true"))        .setHeader(CommonConstants.HMRC_ASSETS_OPERATION_TYPE, constant(CommonConstants.VALIDATION_JSON))        .toD(assetEndpointUrl)

So we have

.setHeader(Exchange.CONTENT_TYPE, constant("application/json;charset=utf-8"))

and

.convertBodyTo(String.class)

But since I have still getting the charector ?.Do I needTo set a setProperty to make sure that convertBodyTo(String.class) uses charset=utf-8

Thank you for any help


Viewing all articles
Browse latest Browse all 1060

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>