Decode hex string to string like hex2bin method in PHP

  ios, php, swift

I need to concat binary with string in swift, to do this we should get same result as PHP ‘hex2bin’ method, I know its strange but we can do this in PHP(and I cant understand what the hell is going on when we are concating binary with string 🙂 ) :

$hexbinary = hex2bin('c0e11c7d13b7bf84b83bb5c8a7873c1c')
$concatResult = $hexbinary . '222'

I tried to decode hex to string in swift with all the available encodings, but no one has the same result:

let decodedHex = String(data: Data(hex: "c0e11c7d13b7bf84b83bb5c8a7873c1c"), encoding: .isoLatin1//Or other possible encodings)
let concatResult = "(decodedHex)222"

Source: Ask PHP