patman: Move unicode helpers to tools

Create helper functions in the tools module to deal with the differences
between unicode in Python 2 (where we use the 'unicode' type) and Python 3
(where we use the 'str' type).

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index 11aeb73..fb9e67c 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -12,6 +12,7 @@
 
 import checkpatch
 import settings
+import tools
 
 # True to use --no-decorate - we check this in Setup()
 use_no_decorate = True
@@ -325,9 +326,8 @@
         raw += LookupEmail(item, alias, raise_on_error=raise_on_error)
     result = []
     for item in raw:
+        item = tools.FromUnicode(item)
         if not item in result:
-            if type(item) == unicode:
-                item = item.encode('utf-8')
             result.append(item)
     if tag:
         return ['%s %s%s%s' % (tag, quote, email, quote) for email in result]