mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-04 04:44:42 +00:00
Add console encoding function to encode Unicode strings in the preferred encoding for the console.
This commit is contained in:
parent
b6ec28c68e
commit
1d07ff3350
1 changed files with 7 additions and 0 deletions
|
|
@ -28,6 +28,13 @@ stderr = codecs.getwriter(i18n.default_encoding)(sys.stderr, errors="ignore")
|
|||
stdout = codecs.getwriter(i18n.default_encoding)(sys.stdout, errors="ignore")
|
||||
|
||||
|
||||
def encode (text):
|
||||
"""Encode text with default encoding if its Unicode."""
|
||||
if isinstance(text, unicode):
|
||||
return text.encode(i18n.default_encoding, 'ignore')
|
||||
return text
|
||||
|
||||
|
||||
class StatusLogger (object):
|
||||
"""Standard status logger. Default output is stderr."""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue