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 3 years have passed since last update.

パーセントエンコーディング

Last updated at Posted at 2022-05-02

常に間違えるのでメモ。パーセントエンコーディングには二種類ある。普通のやつと、空白を "+" に変換する application/x-www-form-urlencoded。application/x-www-form-urlencoded は記憶から抹消するべき。実際に URL のクエリ部分に application/x-www-form-urlencoded を使うとエラーを出す実装も存在するので、歴史的な意味しか無い混乱を生むだけの悪しき存在としか思えない。

  • 普通のやつ
  • application/x-www-form-urlencoded
    • "Hello World!" を "Hello+1%2B1%21" と書く。
    • 用途: URL のクエリ部分や POST の body
    • 仕様: https://url.spec.whatwg.org/#urlencoded-parsing
      • in many ways an aberrant monstrosity と書かれている。。。
    • python: quote_plus("Hello World!")
    • javascript: 存在しない???
      • encodeURI("Hello 1+1!") は 'Hello%201+1!' となる (+ が変換されない)
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?