From 377024ff268e1d051f69f213a8796b95eb1a8a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Fri, 1 Nov 2024 23:48:29 +0800 Subject: [PATCH] fix --- src/LunaTranslator/myutils/utils.py | 47 ++++++++++++----------------- src/plugins/CMakeLists.txt | 2 +- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/src/LunaTranslator/myutils/utils.py b/src/LunaTranslator/myutils/utils.py index a25f139a..e6fcb50b 100644 --- a/src/LunaTranslator/myutils/utils.py +++ b/src/LunaTranslator/myutils/utils.py @@ -384,33 +384,6 @@ def selectdebugfile(path: str, ismypost=False): return p -def checkchaos(text): - code = globalconfig["accept_encoding"] - - text = filter(lambda x: x not in globalconfig["accept_character"], text) - - if globalconfig["accept_use_unicode"]: - _start = globalconfig["accept_use_unicode_start"] - _end = globalconfig["accept_use_unicode_end"] - chaos = False - for ucode in map(lambda x: ord(x), text): - print(ucode, _start, _end) - if ucode < _start or ucode > _end: - chaos = True - break - else: - chaos = True - text = "".join(text) - for c in code: - try: - text.encode(c) - chaos = False - break - except: - pass - return chaos - - def checkencoding(code): try: @@ -1065,3 +1038,23 @@ def is_ascii_symbo(c: str): def is_ascii_control(c: str): return cinranges(c, (0, 0x1F), (0x7F, 0xA0)) + + + +def checkchaos(text): + code = globalconfig["accept_encoding"] + text = filter(lambda x: x not in globalconfig["accept_character"], text) + + if globalconfig["accept_use_unicode"]: + _start = globalconfig["accept_use_unicode_start"] + _end = globalconfig["accept_use_unicode_end"] + return not all(cinranges(c,(_start, _end)) for c in text) + else: + text = "".join(text) + for c in code: + try: + text.encode(c) + return False + except: + pass + return True diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index cd54141f..76da6922 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 53) -set(VERSION_PATCH 7) +set(VERSION_PATCH 8) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)