mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 10:46:04 +03:00
Fix encoding bug in search engine on Windows
Attempt to address issue #29.
This commit is contained in:
parent
b191a977af
commit
882f3dcf0e
1 changed files with 17 additions and 3 deletions
|
@ -26,7 +26,7 @@
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#VERSION: 1.23
|
#VERSION: 1.30
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Fabien Devaux <fab AT gnux DOT info>
|
# Fabien Devaux <fab AT gnux DOT info>
|
||||||
|
@ -42,6 +42,10 @@ import threading
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
from ctypes import WINFUNCTYPE, windll, POINTER, byref, c_int
|
||||||
|
from ctypes.wintypes import LPWSTR, LPCWSTR
|
||||||
|
|
||||||
THREADED = True
|
THREADED = True
|
||||||
CATEGORIES = ('all', 'movies', 'tv', 'music', 'games', 'anime', 'software', 'pictures', 'books')
|
CATEGORIES = ('all', 'movies', 'tv', 'music', 'games', 'anime', 'software', 'pictures', 'books')
|
||||||
|
|
||||||
|
@ -133,7 +137,17 @@ if __name__ == '__main__':
|
||||||
if cat not in CATEGORIES:
|
if cat not in CATEGORIES:
|
||||||
raise SystemExit('Invalid category!')
|
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 = []
|
threads = []
|
||||||
for engine in engines_list:
|
for engine in engines_list:
|
||||||
|
|
Loading…
Reference in a new issue