tnormalize unicode right after reading from file - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 8f314209b4f9c852308eb7e4b31c1e8643283adf DIR parent 1e75d6f8541ab0cd8922ee1ecd6756d4a103a9e5 HTML Author: ThomasV <thomasv@gitorious> Date: Wed, 3 Sep 2014 18:41:25 +0200 normalize unicode right after reading from file Diffstat: M lib/mnemonic.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- DIR diff --git a/lib/mnemonic.py b/lib/mnemonic.py t@@ -20,6 +20,7 @@ import os import hmac import math import hashlib +import unicodedata import ecdsa import pbkdf2 t@@ -43,14 +44,16 @@ class Mnemonic(object): filename = 'english.txt' path = os.path.join(os.path.dirname(__file__), 'wordlist', filename) - lines = open(path,'r').read().strip().split('\n') + s = open(path,'r').read().strip() + s = unicodedata.normalize('NFKD', s.decode('utf8')) + lines = s.split('\n') self.wordlist = [] for line in lines: line = line.split('#')[0] line = line.strip(' \r') assert ' ' not in line if line: - self.wordlist.append(line.decode('utf8')) + self.wordlist.append(line) print_error("wordlist has %d words"%len(self.wordlist)) @classmethod t@@ -60,7 +63,6 @@ class Mnemonic(object): @classmethod def prepare_seed(self, seed): - import unicodedata return unicodedata.normalize('NFKD', unicode(seed.strip())) def mnemonic_encode(self, i):