Class: Wiris::Utf8

Inherits:
Object
  • Object
show all
Defined in:
lib/src-generic/Utf8.rb

Class Method Summary collapse

Class Method Details

.charAt(s, i) ⇒ Object



23
24
25
# File 'lib/src-generic/Utf8.rb', line 23

def self.charAt(s, i)
	return s[i]
end

.charCodeAt(s, index) ⇒ Object



11
12
13
# File 'lib/src-generic/Utf8.rb', line 11

def self.charCodeAt(s, index)
	return s.codepoints.to_a[index]
end

.fromBytes(bytes) ⇒ Object



7
8
9
# File 'lib/src-generic/Utf8.rb', line 7

def self.fromBytes(bytes)
	return bytes.pack("C*")
end

.getLength(s) ⇒ Object



19
20
21
# File 'lib/src-generic/Utf8.rb', line 19

def self.getLength(s)
	return s.length
end

.toBytes(str) ⇒ Object



3
4
5
# File 'lib/src-generic/Utf8.rb', line 3

def self.toBytes(str)
	return str.force_encoding("UTF-8").bytes.to_a
end

.uchr(code) ⇒ Object



15
16
17
# File 'lib/src-generic/Utf8.rb', line 15

def self.uchr(code)
	return code.chr(Encoding::UTF_8)
end