I have a web service that receives a parameter in ISO-8859-1 encoding.
But when I try to read it from the request, I get this characters:
�����
I've tryied all these approaches, but none of the convert the given string to the expected one (áéíóú):
val a = new String(_html.getBytes());
val b = new String(_html.getBytes(), "UTF-8")
val c = new String(_html.getBytes(), "ISO-8859-1")
val d = new String(_html.getBytes("ISO-8859-1"), "UTF-8")
val e = new String(_html.getBytes("ISO-8859-1"), "ISO-8859-1")
val f = new String(_html.getBytes("UTF-8"), "UTF-8")
val g = new String(_html.getBytes("UTF-8"), "ISO-8859-1")
Here is my action:
val inboundMessageForm = Form(
mapping(
"html" -> text)(InboundMessage.apply)(InboundMessage.unapply))
def forward = Action(parse.multipartFormData) { implicit request =>
val inboundMessage = inboundMessageForm.bindFromRequest.get
// inboundMessage.html => �����
}
What can I do to solve this problem?
If you are running windows, the default encoding (at least in the states, not sure about the rest of the world) is actually "windows-1252", not "ISO-8859-1". You could also try "UTF-16" in case those characters aren't included in the "UTF-8" encoding (which most things other than windows use).
Here is the answer to this question:
https://groups.google.com/forum/?fromgroups=#!topic/play-framework/R0ayxNuzR74