Sha256: 7e7948d1c293e7d318cb9dc29b6d10ab940182599a0a2bf062fc45abacc975eb
Contents?: true
Size: 985 Bytes
Versions: 2
Compression:
Stored size: 985 Bytes
Contents
module TextMagic class API module Charset GSM_CHARSET = "@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞ\e\f^{}\\[~]|€ÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?¡"\ "ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà".scan(/./u).freeze ESCAPED_CHARS = "{}\\~[]|€".freeze # Returns +true+ if the supplied text contains only characters from # GSM 03.38 charset, otherwise it returns +false+. def gsm?(text) text.scan(/./u).each { |c| return false unless GSM_CHARSET.include?(c) } true end alias is_gsm gsm? # Returns +true+ if the supplied text contains characters outside of # GSM 03.38 charset, otherwise it returns +false+. def unicode?(text) !is_gsm(text) end alias is_unicode unicode? def real_length(text, unicode) text.size + (unicode ? 0 : text.scan(/[\{\}\\~\[\]\|€]/).size) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
textmagic-0.7.1 | lib/textmagic/charset.rb |
textmagic-0.7.0 | lib/textmagic/charset.rb |