module TextMagic::API::Charset
Constants
- ESCAPED_CHARS
- GSM_CHARSET
Public Instance Methods
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/textmagic/charset.rb, line 14 def gsm?(text) text.scan(/./u).each { |c| return false unless GSM_CHARSET.include?(c) } true end
Also aliased as: is_gsm
real_length(text, unicode)
click to toggle source
# File lib/textmagic/charset.rb, line 27 def real_length(text, unicode) text.size + (unicode ? 0 : text.scan(/[\{\}\\~\[\]\|€]/).size) end
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/textmagic/charset.rb, line 22 def unicode?(text) !is_gsm(text) end
Also aliased as: is_unicode