From 397809cd7b790a398193c45d4336698487b4a9e1 Mon Sep 17 00:00:00 2001 From: Josip Pisoj Date: Mon, 8 Mar 2010 18:13:43 +0000 Subject: [PATCH] bug #3662: SoundEx works only for ascii characters svn: r14701 --- src/soundex.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/soundex.py b/src/soundex.py index c9c00d35f..753db1b44 100644 --- a/src/soundex.py +++ b/src/soundex.py @@ -28,6 +28,7 @@ Provide soundex calculation # #------------------------------------------------------------------------- import string +import unicodedata #------------------------------------------------------------------------- # @@ -45,11 +46,11 @@ TABLE = string.maketrans('ABCDEFGIJKLMNOPQRSTUVXYZ', #------------------------------------------------------------------------- def soundex(strval): "Return the soundex value to a string argument." - - strval = strval.upper().strip() + + strval = unicodedata.normalize('NFKD', + strval.upper().strip()).encode('ASCII', 'ignore') if not strval: return "Z000" - strval = strval.encode('iso-8859-1') str2 = strval[0] strval = strval.translate(TABLE, IGNORE) if not strval: