I’m using Spring/Roo for an app server, and need to be able to post some special characters. Specifically, characters like the Yen symbol, or Euro symbol. When I receive these characters on my server, and display them in console, they appear as “?”. How can they be properly encoded and received?
Share
There are a couple of possible failure points here.
First, I’d check to see if the console supports the characters in question:
System.outSystem.outis encoding them to, the characters will not display correctlyInstead of trying to print characters as literal, cast to
intand print the hex value – then check the value against the Unicode charts.Lossy or incorrect conversions can also happen between the browser and the server. Ideally, the server should use UTF-8 for encoding and decoding. If the encoding used by the browser when it encodes the data does not support the characters, they will be lossily encoded; the browser usually picks an encoding based on the encoding sent by the server for the GET request (or more rarely from a form attribute). Inspect the
Accept-Charsetheader being sent with your data (you can do this with something like Firebug or Fiddler). I don’t know anything about Roo, but there’s bound to be some mechanism to configure encodings.