What's your input character set? Latin-X? UTF-Y?
The demo section of GSM::Nbit provides a good hint:
use Encode qw/encode decode/;
...
# We need to encode it first - for details see:
# http://www.dreamfabric.com/sms/default_alphabet.html
my $txt0338 = encode("gsm0338", $txt); # <--- look!
...
I havn't checked it, but
Encode seems to have solved
your problem already or can do most of the heavy lifting for you?
See also:
Encode::GSM0338
The link to dreamfabric seems no longer availabe, but the
Wayback Machine still
remembers.