mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-10 01:21:00 +00:00
str() for unicode_safe objects
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2324 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
daf6f351c4
commit
bf89b8e9a9
1 changed files with 3 additions and 3 deletions
|
|
@ -33,16 +33,16 @@ def unicode_safe (s, encoding="iso-8859-1"):
|
|||
characters of the given encoding will be ignored.
|
||||
|
||||
@param s: the string to be decoded
|
||||
@type s: unicode or encoded string
|
||||
@type s: any object except None
|
||||
@return: if s is already unicode, return s unchanged; else return
|
||||
decoded unicode string
|
||||
decoded unicode string of str(s)
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert s is not None, "argument to unicode_safe was None"
|
||||
if isinstance(s, unicode):
|
||||
# s is already unicode, nothing to do
|
||||
return s
|
||||
return unicode(s, encoding, "ignore")
|
||||
return unicode(str(s), encoding, "ignore")
|
||||
|
||||
|
||||
def url_unicode_split (url):
|
||||
|
|
|
|||
Loading…
Reference in a new issue