mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-26 19:20:32 +00:00
Fix encoding bug in search engine on Windows
Attempt to address issue #29.
This commit is contained in:
parent
b191a977af
commit
882f3dcf0e
@ -26,7 +26,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
#VERSION: 1.23
|
||||
#VERSION: 1.30
|
||||
|
||||
# Author:
|
||||
# Fabien Devaux <fab AT gnux DOT info>
|
||||
@ -42,6 +42,10 @@ import threading
|
||||
import os
|
||||
import glob
|
||||
|
||||
if os.name == 'nt':
|
||||
from ctypes import WINFUNCTYPE, windll, POINTER, byref, c_int
|
||||
from ctypes.wintypes import LPWSTR, LPCWSTR
|
||||
|
||||
THREADED = True
|
||||
CATEGORIES = ('all', 'movies', 'tv', 'music', 'games', 'anime', 'software', 'pictures', 'books')
|
||||
|
||||
@ -132,8 +136,18 @@ if __name__ == '__main__':
|
||||
|
||||
if cat not in CATEGORIES:
|
||||
raise SystemExit('Invalid category!')
|
||||
|
||||
what = '+'.join(sys.argv[3:])
|
||||
|
||||
search_tokens = sys.argv[3:]
|
||||
if os.name == 'nt':
|
||||
# We need this trick on Windows to get UTF-8 encoded arguments
|
||||
GetCommandLineW = WINFUNCTYPE(LPWSTR)(("GetCommandLineW", windll.kernel32))
|
||||
CommandLineToArgvW = WINFUNCTYPE(POINTER(LPWSTR), LPCWSTR, POINTER(c_int)) (("CommandLineToArgvW", windll.shell32))
|
||||
argc = c_int(0)
|
||||
argv_unicode = CommandLineToArgvW(GetCommandLineW(), byref(argc))
|
||||
argv = [argv_unicode[i].encode('utf-8') for i in range(0, argc.value)]
|
||||
search_tokens = argv[3:]
|
||||
|
||||
what = '+'.join(search_tokens)
|
||||
|
||||
threads = []
|
||||
for engine in engines_list:
|
||||
|
Loading…
Reference in New Issue
Block a user