Mercurial > dive4elements > river
diff flys-backend/contrib/shpimporter/utils.py @ 4935:c0a58558b817 dami
Importer: - Handle regular expressions for attribute names
- Convert Strings to UTF-8
- Add regular expressions for hws_points values
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 31 Jan 2013 12:23:41 +0100 |
parents | 1f6e544f7a7f |
children | 174fbaa3d344 |
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/utils.py Thu Jan 31 12:21:59 2013 +0100 +++ b/flys-backend/contrib/shpimporter/utils.py Thu Jan 31 12:23:41 2013 +0100 @@ -20,6 +20,17 @@ return shapes +def getUTF8(string): + """ + Tries to convert the string to a UTF-8 encoding by first checking if it + is UTF-8 and then trying cp1252 + """ + try: + return unicode.encode(unicode(string, "UTF-8"), "UTF-8") + except UnicodeDecodeError: + # Probably European Windows names so lets try again + return unicode.encode(unicode(string, "cp1252"), "UTF-8") + def getUTF8Path(path): """ Tries to convert path to utf-8 by first checking the filesystemencoding