0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

URLRequest のURLに"?x=ほげ"のようにパラメタを埋め込むとSJISでエンコードされる問題は URLVariables を使うことで解決する

Last updated at Posted at 2013-02-15

例えば

var req:URLRequest = new URLRequest("http://www.example.com/entries?tag=ほげ");
var loader:URLLoader = new URLLoader();
loader.load();

とすると、日本語の値(”ほげ”)が SJIS としてサーバ側に渡されてしまう。(環境による?)

パラメタの値をちゃんと UTF-8 でエンコードするには、以下のようにURLVariables のインスタンスのプロパティに値をセットし、URLRequest の data プロパティにセットして load() を行う。

var req:URLRequest = new URLRequest("http://www.example.com/entries");
var vars:URLVariables = new URLVariables();
vars.tags = "ほげ";
req.data = vars;
var loader:URLLoader = new URLLoader();
loader.load();

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?