Quick actions

cmd+k|ctrl+k

Navigation

Languages

encoding

Snippet info

Language

Ruby

Visibility

public

Author

hyrious

Created

2021-08-29T12:48:52.477793Z

Updated

2021-08-29T12:48:52.477793Z

def zero bytes, sep = ' '
  bytes.unpack('C*').map { |e| '%02x' % e }.join sep
end

def table left, right
  puts "#{'%8s' % left}: #{right}"
end

def one s, t
  table t, (zero s.encode t)
end

def two s
  table 'display', s
  table 'unicode', s.codepoints.map { |e| 'U+%02X' % e }.join(' ')
end

def three s, *t
  two s
  t.each { |u| one s, u }
end

three "あ", 'utf-8', 'utf-16', 'utf-32', 'gb18030'
INFO