Sha256: c61238b0abec536f3989556c3017540f9a1ff597c87a6192bd07f0ad14383baf

Contents?: true

Size: 739 Bytes

Versions: 11

Compression:

Stored size: 739 Bytes

Contents

module TextMagic

  class API

    module Charset

      GSM_CHARSET = "@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞ\e\f^{}\\[~]|€ÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà".scan(/./u)

      # Returns +true+ if the supplied text contains only characters from
      # GSM 03.38 charset, otherwise it returns +false+.
      def is_gsm(text)
        text.scan(/./u).each { |c| return false unless GSM_CHARSET.include?(c) }
        true
      end

      # Returns +true+ if the supplied text contains characters outside of
      # GSM 03.38 charset, otherwise it returns +false+.
      def is_unicode(text)
        !is_gsm(text)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
bobes-textmagic-0.2.0 lib/charset.rb
bobes-textmagic-0.2.1 lib/charset.rb
bobes-textmagic-0.2.2 lib/charset.rb
bobes-textmagic-0.2.3 lib/charset.rb
bobes-textmagic-0.3.0 lib/charset.rb
bobes-textmagic-0.3.1 lib/charset.rb
textmagic-0.2.1 lib/charset.rb
textmagic-0.2.0 lib/charset.rb
textmagic-0.3.0 lib/charset.rb
textmagic-0.2.2 lib/charset.rb
textmagic-0.3.1 lib/charset.rb