GSMEncoder encodes and decodes Ruby Strings to and from the SMS default alphabet. It also supports the default extension table and Spanish language extension table. The default alphabet and it's extension table is defined in GSM 03.38.
This is a fork of Yury's GsmEncoder which is a port of Twitter's Java implementation. Yury's tool only had the Spanish extension table, the current fork incorporates the basic table (used by most USA telecommunications providers; and many providers across the globe) and a way to choose among both encodings.
NOTE: ruby >= 1.9.2 is required
gem install gsm_encoder
require 'gsm_encoder'
# encoding
GSMEncoder.encode 'hello @ world' # => binary string
# decoding
GSMEncoder.decode(GSMEncoder.encode('hi')) # => 'hi'
# can encode?
GSMEncoder.can_encode?('`') # => false
# replaces unsupported chars with '?'
GSMEncoder.encode('`') # => '?'
# replaces unsupported chars with a provided value ' '
GSMEncoder.encode('`', ' ') # => ' '
Added support for basic extension table besides Spanish.
Even faster. About 4 times. Many thanks to @dlarrabee.
Code cleanup and speedup.
Adds the ability to provide the character used when encoding unsupported strings.
Fixed bug when encoding line feed & carriage return.
Added support for Spanish shift.