class Persian::Unicode

Persian Unicode class

Public Class Methods

codepoint_to_char(char) click to toggle source
# File lib/persian/unicode.rb, line 6
def self.codepoint_to_char(char)
  return [char].pack('U') if char.is_a? Fixnum
  [char.hex].pack('U')
end
lre(text) click to toggle source

Return text between LETF-TO-RIGHT EMBEDDING(U+202A) and Pop Directional Format(U+202C)

# File lib/persian/unicode.rb, line 20
def self.lre(text)
  rle_tag = 0x202A
  pop_tag = 0x202C

  codepoint_to_char(rle_tag) + text + codepoint_to_char(pop_tag)
end
lro(text) click to toggle source
# File lib/persian/unicode.rb, line 34
def self.lro(text)
  rlo_tag = 0x202D
  pop_tag = 0x202C

  codepoint_to_char(rlo_tag) + text + codepoint_to_char(pop_tag)
end
rle(text) click to toggle source

Return text between RIGHT-TO-LETF EMBEDDING(U+202B) and Pop Directional Format(U+202C)

# File lib/persian/unicode.rb, line 12
def self.rle(text)
  lre_tag = 0x202B
  pop_tag = 0x202C

  codepoint_to_char(lre_tag) + text + codepoint_to_char(pop_tag)
end
rlo(text) click to toggle source
# File lib/persian/unicode.rb, line 27
def self.rlo(text)
  lro_tag = 0x202E
  pop_tag = 0x202C

  codepoint_to_char(lro_tag) + text + codepoint_to_char(pop_tag)
end