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?

JavaScript decodeURI()関数:encodeURI()でエンコードしたURLをデコード

0
Posted at

概念と使用方法

decodeURI()関数はencodeURI()でエンコードされたURLをデコードする際に使用する関数です。
つまり、encodeURI()でエンコードされた特殊文字のみをデコードします。

特徴

  • encodeURI()がエンコードしない文字(例:/、?、:、&、#)はデコードされません。
  • このような文字を含むURLをデコードする場合は、代わりにdecodeURIComponent()を使用してください。

基本の例

const uri = "https://www.example.com/?x=サンプル値";
const encoded = encodeURI(uri);

console.log(encoded);
// 出力: "https://www.example.com/?x=%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E5%80%A4"

const decoded = decodeURI(encoded);

console.log(decoded);
// 出力: "https://www.example.com/?x=サンプル値"

構文

decodeURI(encodedURI)

const encodedURI = "https://www.example.com/%E3%83%A1%E3%83%BC%E3%83%AB"; // エンコードされたURI
const decodedString = decodeURI(encodedURI); // デコードされた文字列

console.log(decodedString); // 出力: "https://www.example.com/メール"

参考資料

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?