summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2013-09-04 16:04:26 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-09-14 08:01:33 +0900
commit6b993c5e2b409e80d9776c24367fb4c3b8b4c778 (patch)
treec3a9d1b063f3cde7da7b6a80c7ea0fd58f76e2e6
parentd8f1ad7af356e81e5327af2683a14b82e5a2aced (diff)
stringify: add 'utf-8' type
to be used for of-wire port name etc. Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/stringify.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/ryu/lib/stringify.py b/ryu/lib/stringify.py
index a575e8ee..a88cc22c 100644
--- a/ryu/lib/stringify.py
+++ b/ryu/lib/stringify.py
@@ -60,8 +60,19 @@ class AsciiStringType(TypeDescr):
return v.encode('ascii')
+class Utf8StringType(TypeDescr):
+ @staticmethod
+ def encode(v):
+ return unicode(v, 'utf-8')
+
+ @staticmethod
+ def decode(v):
+ return v.encode('utf-8')
+
+
_types = {
'ascii': AsciiStringType,
+ 'utf-8': Utf8StringType,
}