Set ascii to the default encoding.
This commit is contained in:
@@ -8,18 +8,17 @@ import requests
|
||||
|
||||
from .errors import SubmissionURLError, SubredditNameError
|
||||
|
||||
FORCE_ASCII = True
|
||||
UNICODE = False
|
||||
|
||||
def clean(string):
|
||||
|
||||
encoding = 'ascii' if FORCE_ASCII else 'utf-8'
|
||||
encoding = 'utf-8' if UNICODE else 'ascii'
|
||||
|
||||
if six.PY2:
|
||||
out = string.encode(encoding, 'replace')
|
||||
else:
|
||||
out = string.encode().decode(encoding, 'replace')
|
||||
|
||||
out = out.replace('\\', '')
|
||||
return out
|
||||
|
||||
def split_text(big_text, width):
|
||||
|
||||
@@ -45,8 +45,8 @@ def main():
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument('-s', dest='subreddit', help='subreddit name')
|
||||
parser.add_argument('-l', dest='link', help='full link to a submission')
|
||||
parser.add_argument('--force-ascii', dest='force_ascii',
|
||||
help='disable unicode', action='store_true')
|
||||
parser.add_argument('--unicode', help='enable unicode (beta)',
|
||||
action='store_true')
|
||||
|
||||
group = parser.add_argument_group(
|
||||
'authentication (optional)',
|
||||
@@ -64,7 +64,7 @@ def main():
|
||||
if getattr(args, key) is None:
|
||||
setattr(args, key, val)
|
||||
|
||||
content.FORCE_ASCII = args.force_ascii
|
||||
content.UNICODE = args.unicode
|
||||
|
||||
if args.subreddit is None:
|
||||
args.subreddit = 'front'
|
||||
|
||||
Reference in New Issue
Block a user