Browse Source

Fix subprocess encoding

doc-issue-template
MrS0m30n3 10 years ago
parent
commit
3ae8ccc4f8
1 changed files with 13 additions and 1 deletions
  1. 14
      youtube_dl_gui/Utils.py

14
youtube_dl_gui/Utils.py

@ -2,6 +2,7 @@
import os
import sys
import locale
def remove_empty_items(array):
return [x for x in array if x != '']
@ -11,10 +12,21 @@ def remove_spaces(string):
def string_to_array(string, char=' '):
return string.split(char)
def preferredencoding():
try:
pref = locale.getpreferredencoding()
u'TEST'.encode(pref)
except:
pref = 'UTF-8'
return pref
def get_encoding():
if sys.version_info >= (3, 0):
return None
if sys.platform == 'win32':
return sys.getfilesystemencoding()
# Refer to http://stackoverflow.com/a/9951851/35070
return preferredencoding()
return None
def encode_list(data_list, encoding):

Loading…
Cancel
Save