Method: Bagua::Tri.decode

Defined in:
lib/bagua/tri.rb

.decode(grams) ⇒ Object

TODO:

Add an option to choose the encoding.

Note:

Chomps trailing null characters, as they are the result of zero padding added when the number of bits being encoded in the trigrams is not an even multiple of 3.

Decodes a string of trigrams into a UTF-8 string.



15
16
17
# File 'lib/bagua/tri.rb', line 15

def self.decode(grams)
  return to_bytes(grams).pack('C*').chomp("\000").force_encoding('utf-8')
end