# encoding: ascii
# api: powershell
# title: Correction
# description: Dear scripters,
# version: 0.1
# type: function
# author: Klaus Schulte
# license: CC0
# function: Convert-ToCHexString
# x-poshcode-id: 3271
# x-archived: 2015-04-30T04:17:04
# x-published: 2012-03-10T04:21:00
#
# the original script won’t work, beacuse a “)” is missing in the param statement and the automatic $input variable is used as a parameter to the function but not in the Encoding.GetBytes method where an undefined parameter $str is encountered!
# I would prefer to just convert strings into char arrays and return the byte code as hex chars and wrap it into a small advanced function that returns the hex chars joined by a seperator like ‘,’
# Klaus (Schulte)
#
function Convert-ToCHexString {
[CmdletBinding()]
param (
    [Parameter(ValueFromPipeline=$true,Mandatory=$true)][string]$str
)    
   process { ($str.ToCharArray() | %{ "0x{0:X2}" -f [int]$_  }) -join ',' }
}
