Sha256: 6a4ff57df64f617da214e0bf891ba22897ac9f7d1f2b3453c7e2b94729faf375

Contents?: true

Size: 749 Bytes

Versions: 3

Compression:

Stored size: 749 Bytes

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Utils
    module CodePoints

      class << self

        def to_char(code_point)
          [code_point].pack('U*')
        end

        def from_char(char)
          char.unpack('U*').first
        end

        def from_chars(chars)
          chars.map { |char| from_char(char) }
        end

        def to_chars(code_points)
          code_points.map { |code_point| to_char(code_point) }
        end

        def from_string(str)
          from_chars(str.chars.to_a)
        end

        def to_string(code_points)
          code_points.map{ |code_point| to_char(code_point) }.join
        end

      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
twitter_cldr-1.8.1 lib/twitter_cldr/utils/code_points.rb
twitter_cldr-1.8.0 lib/twitter_cldr/utils/code_points.rb
twitter_cldr-1.7.0 lib/twitter_cldr/utils/code_points.rb