# encoding: ascii
# api: powershell
# title: quoted printable
# description: quoted printable decoder (assumes you want to output strings as opposed to a byte buffer).
# version: 0.1
# type: function
# author: Public Domain
# license: CC0
# function: ConvertFrom-QuotedPrintable
# x-poshcode-id: 6204
# x-archived: 2016-03-18T22:00:36
# x-published: 2016-02-07T19:59:00
#
#
function ConvertFrom-QuotedPrintable {
	[OutputType([string])]
	[CmdletBinding()]
	param(
		[Parameter(ValueFromPipeline)]
		[string]$InputObject
,
		[Parameter(Mandatory)]
		[System.Text.Encoding]$Encoding = [System.Text.Encoding]::UTF8
	)
	begin {
		$buf = ''
	}
	process {
		$buf += [regex]::Replace(
			[regex]::Replace($InputObject, "=[ `t]*(?:`r`n|`n|\z)", ''),
			'=[0-9a-fA-F]{2}',
			[System.Text.RegularExpressions.MatchEvaluator]{[string][char][int]::Parse($args[0].Value.Substring(1), [System.Globalization.NumberStyles]::AllowHexSpecifier)}
		)
	}
	end {
		$Encoding.GetString([byte[]][char[]]$buf)
	}
}
