-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Way to specify additional encoding for options decoding #6119
Comments
The only problem with respecting |
We could define a new command line option to set the encoding only for the We basically search the sys.argv for the new option and if one is presented we extract the given encoding. Then we can use this encoding to further decode the Example: + def compat_conf(conf, encoding=preferredencoding()):
if sys.version_info < (3,):
+ return [a.decode(encoding, 'replace') for a in conf]
return conf
+ # Try to extract the encoding for the command_line_conf decode process
+ enc = sys.argv[sys.argv.index(str('--new-option')) + 1] if str('--new-option') in sys.argv else None
+ command_line_conf = compat_conf(sys.argv[1:], enc) |
Hi @dstftw
On your commit you replaced the utf-8 encoding with the preferredencoding() function. I just wanted to ask if it is possible to use an existing command line option like --encoding in order to specify an additional encoding.
For example if someone wants to call youtube-dl.exe on windows using the subprocess module (which does not support unicode on Python 2.x) he has to encode the input to the subprocess module. With your implementation the user has to use the locale.getpreferredencoding() to encode the data else the decoding on the side of youtube-dl will fail. But if the returned encoding from locale.getpreferredencoding() can't encode the input some of the characters get lost.
I am currently working on #5527 so it would be helpful if the user had the power to select the encoding both for the encoding and the decoding phase.
We can achieve this behaviour using something like this on options.py
The text was updated successfully, but these errors were encountered: