Pack Template UTF-8

Submitted By:
znz

Difficulty:
Easy

Tags:
pack

Instructions:
Write pack template of UTF-8.

Code:
# -*- coding: utf-8 -*-
assert_equal [0, 1].pack(___), "\000\001"
assert_equal [0x7f].pack(___), "\177"
assert_equal [0x80].pack(___), "\302\200"
assert_equal "\u3042".unpack(___), [0x3042]
assert_equal "あいうえお".unpack(___), [12354, 12356, 12358, 12360, 12362]
assert_equal [12354, 12356, 12358, 12360, 12362].pack(___), "あいうえお"

Your Solution

Ruby 1.9.3

Back to Problems