Class: LZString::UTF16

Inherits:
Object
  • Object
show all
Defined in:
lib/lz_string/utf16.rb

Overview

UTF16 compressing algorithm.

Class Method Summary collapse

Class Method Details

.compress(input) ⇒ Object

Parameters:

  • input (String)


5
6
7
8
9
# File 'lib/lz_string/utf16.rb', line 5

def self.compress(input)
  return "" if (input == nil)

  LZString::Base.compress(input, 15, lambda { |a| (a + 32).chr("UTF-8") }) + " "
end

.decompress(compressed) ⇒ Object

Parameters:

  • compressed (String)


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/lz_string/utf16.rb', line 12

def self.decompress(compressed)
  return "" if (compressed == nil)
  return nil if (compressed == "")

  LZString::Base.decompress(
    compressed.length,
    16384,
    lambda { |index| compressed[index].ord - 32 },
    "UTF-8"
  )
end