0

I'm Japanese. I'm using Play Framework2.2. I use cookie like this.

public class AppController extends Application {
   public static Result index() {

      response().setCookie("myName",  "くっきー"); //Japanese String
      return ok(index.render());
   }

   public static Result result() {
      response().setCookie("myName",  "くっきー"); //Japanese String
      //garbled characters
      return ok(request().cookie("myName").value());
   }
}

But, value is garbled characters.

if I use java.net.URLEncoder, I succeeded in saving and extract Japanese String. But I wonder Play Framework has a more useful solution?

  • Are you using UTF encoding? – Alex May 20 '16 at 08:04
  • yes URLEncoder.encode("くっきー","UTF-8") and URLDecoder.decode(request().cookie("myName").value(),"UTF-8") –  May 20 '16 at 08:08
  • I don't think you can use Japanese characters in cookies (http://stackoverflow.com/questions/1969232/allowed-characters-in-cookies). – Kris May 23 '16 at 12:20

0 Answers0