Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/gollum/uri_encode_component.rb

Overview

define charCodeAt on String

Instance Method Summary collapse

Instance Method Details

#charCodeAt(k) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/gollum/uri_encode_component.rb', line 42

def charCodeAt(k)
  # use scan, nil check, and unpack instead of ord for 1.8
  # 1.9 can simply use self[k].ord
  # http://stackoverflow.com/questions/7793177/split-utf8-string-regardless-of-ruby-version
  c = self.scan(/./mu)[k]
  return nil if c.nil?
  c.unpack('U')[0]
end