# Encode UTF-8 string as GSM 03.38 7-bit string perl -MEncode -ple '$_=encode "GSM0338", decode "UTF-8", $_; $l=length($_)*2; $l -= $l>6 ? int($l/8) : 0; $b=unpack "b*", $_; $b=~s/(.{7})./$1/g; $_=sprintf "%02X%s", $l, uc unpack "H*", pack "b*", $b' # Decode GSM 03.38 7-bit string to UTF-8 perl -MEncode -ple 's/^(..)//; $l = (hex($1)+2)*4; $b=unpack "b*", pack "H*", $_; $b=~s/(.{7})/$1./g; $b=substr $b, 0, $l; $b=substr $b, 0, int(length($b)/8)*8; $_=decode "GSM0338", pack "b*", $b;' # Encode UTF-8 string as ESTI GSM 03.38 IRA hex string perl -MEncode -ple '$_=uc unpack "H*", encode "GSM0338", decode "UTF-8", $_' # Decode ESTI GSM 03.38 to UTF-8 IRA hex string perl -MEncode -ple '$_=encode "UTF-8", decode "GSM0338", pack "H*", $_' # Encode UTF-8 as UCS2-LE IRA hex string perl -MEncode -ple '$_=uc unpack "H*", pack "n*", unpack "v*", encode "UCS-2LE", decode "UTF-8", $_' # Decode UCS2-LE IRA hex string to UTF-8 perl -MEncode -ple '$_=encode "UTF-8", decode "UCS-2LE", pack "v*", unpack "n*", pack "H*", $_'