関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------ | |
# 指定した文字コードより、文字列をURLエンコードする | |
# 関数名:Get-URLEncode | |
# 引数 :VALUE URLエンコードする文字列 | |
# :ENCODING 文字コード | |
# 戻り値:URLエンコードした文字列 | |
# ------------------------------------------------------------------ | |
function Get-URLEncode([String]$VALUE, [String]$ENCODING){ | |
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web") | |
$enc= [System.Text.Encoding]::GetEncoding($ENCODING) | |
return [System.Web.HttpUtility]::UrlEncode($VALUE,$enc) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------ | |
# 指定した文字コードより、文字列をURLデコードする | |
# 関数名:Get-URLDecode | |
# 引数 :VALUE URLデコードする文字列 | |
# :ENCODING 文字コード | |
# 戻り値:URLデコードした文字列 | |
# ------------------------------------------------------------------ | |
function Get-URLDecode([String]$VALUE, [String]$ENCODING){ | |
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web") | |
$enc= [System.Text.Encoding]::GetEncoding($ENCODING) | |
return [System.Web.HttpUtility]::UrlDecode($VALUE,$enc) | |
} |
実行例
# 実行 PS > Get-URLEncode -VALUE "あいうえお" -ENCODING "utf-8" %e3%81%82%e3%81%84%e3%81%86%e3%81%88%e3%81%8a
# 実行 PS > Get-URLDecode-VALUE "%e3%81%82%e3%81%84%e3%81%86%e3%81%88%e3%81%8a" -ENCODING "utf-8" あいうえお