错误的字符集编码与Play Framework 2.1 [英] Wrong Charset Encoding with Play Framework 2.1

查看:155
本文介绍了错误的字符集编码与Play Framework 2.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web服务接收ISO-8859-1编码中的参数。

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")

这是我的操作:

  val inboundMessageForm = Form(
    mapping(
      "html" -> text)(InboundMessage.apply)(InboundMessage.unapply))

  def forward = Action(parse.multipartFormData) { implicit request =>
    val inboundMessage = inboundMessageForm.bindFromRequest.get

        // inboundMessage.html =>  �����
   }

我该如何解决这个问题? p>

What can I do to solve this problem?

推荐答案

这是此问题的答案:

https://groups.google.com/forum/?fromgroups=#!topic / play-framework / R0ayxNuzR74

这篇关于错误的字符集编码与Play Framework 2.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆