class Smshelper::Languagetools::Charset

Constants

ESCAPED_CHARS
GSM_CHARSET

Public Instance Methods

is_gsm(text) click to toggle source

Returns true if the supplied text contains only characters from GSM 03.38 charset, otherwise it returns false.

# File lib/smshelper/languagetools/languagetools.rb, line 37
def is_gsm(text)
  text.scan(/./u).each { |c| return false unless GSM_CHARSET.include?(c) }
  true
end
is_unicode(text) click to toggle source

Returns true if the supplied text contains characters outside of GSM 03.38 charset, otherwise it returns false.

# File lib/smshelper/languagetools/languagetools.rb, line 44
def is_unicode(text)
  !is_gsm(text)
end
real_length(text, unicode) click to toggle source
# File lib/smshelper/languagetools/languagetools.rb, line 48
def real_length(text, unicode)
  text.size + (unicode ? 0 : text.scan(/[\{\}\\~\[\]\|€]/).size)
end