user3778222
user3778222

Reputation: 23

Pound symbol comes in camel message as?

I am facing issue with Pound symbol coming in my messages to camel route , The pound symbol when comes in json request on my camel rest endpoint , it gets converted to "?" the same gets shown on log too.

I have tried below ways to fix this by setting convertBodyTo tag charset to utf-8 but it didn't worked.

Camel version used is 2.10. Locale is : en_US.

Here is the route :

<from uri="jetty:http://localhost:8080/testService"/>
<camel:convertBodyTo type="String" charset="utf-8" /> <camel:log message="Message Body: ${body}" /> <to uri="jetty:http://localhost:8080/testEndpoints"/>

Upvotes: 1

Views: 578

Answers (1)

Ralf
Ralf

Reputation: 6853

You need to know the encoding the client uses when POSTing the JSON. The browser should send you the encoding information in the Content-Type header field.

If the Pound sign shows as a single question mark, that indicates that the stream has a single-byte encoding. If it is multi-byte and then read with a single byte encoding it would show up as two garbage characters, not one. If the Content-Type header does not specify the encoding, then try setting the western single byte encoding ISO-8859-1 instead of UTF-8 and see if that works. As your locale is en_US the default encoding is probably US-ASCII.

Upvotes: 2

Related Questions