Does an ASCII normalization of unicode strings # Reference: http://www.peterbe.com/plog/unicode-to-ascii >>> normalizeUnicode(u'\\u0161u\\u0107uraj') == u'sucuraj' True >>> normalizeUnicode(getUnicode(decodeHex("666f6f00626172"))) == u'foobar' True
(value, charset=string.printable[:string.printable.find(' ') + 1])
| 4238 | return retVal |
| 4239 | |
| 4240 | def normalizeUnicode(value, charset=string.printable[:string.printable.find(' ') + 1]): |
| 4241 | """ |
| 4242 | Does an ASCII normalization of unicode strings |
| 4243 | |
| 4244 | # Reference: http://www.peterbe.com/plog/unicode-to-ascii |
| 4245 | |
| 4246 | >>> normalizeUnicode(u'\\u0161u\\u0107uraj') == u'sucuraj' |
| 4247 | True |
| 4248 | >>> normalizeUnicode(getUnicode(decodeHex("666f6f00626172"))) == u'foobar' |
| 4249 | True |
| 4250 | """ |
| 4251 | |
| 4252 | retVal = value |
| 4253 | |
| 4254 | if isinstance(value, six.text_type): |
| 4255 | retVal = unicodedata.normalize("NFKD", value) |
| 4256 | retVal = "".join(_ for _ in retVal if _ in charset) |
| 4257 | |
| 4258 | return retVal |
| 4259 | |
| 4260 | def safeSQLIdentificatorNaming(name, isTable=False): |
| 4261 | """ |
no test coverage detected
searching dependent graphs…