mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-11 17:44:28 +05:00
fix: ensure encoding
Use an alternative approach as in #587 as it introduces an unexpected behavior in printing output Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
6
kiauh.py
6
kiauh.py
@@ -9,13 +9,7 @@
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||
# ======================================================================= #
|
||||
|
||||
import io
|
||||
import sys
|
||||
|
||||
from kiauh.main import main
|
||||
|
||||
# ensure that all output is utf-8 encoded
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -6,15 +6,24 @@
|
||||
# #
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||
# ======================================================================= #
|
||||
import io
|
||||
import sys
|
||||
|
||||
from core.logger import Logger
|
||||
from core.menus.main_menu import MainMenu
|
||||
from core.settings.kiauh_settings import KiauhSettings
|
||||
|
||||
|
||||
def ensure_encoding() -> None:
|
||||
if sys.stdout.encoding == "UTF-8" or not isinstance(sys.stdout, io.TextIOWrapper):
|
||||
return
|
||||
sys.stdout.reconfigure(encoding="utf-8")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
KiauhSettings()
|
||||
ensure_encoding()
|
||||
MainMenu().run()
|
||||
except KeyboardInterrupt:
|
||||
Logger.print_ok("\nHappy printing!\n", prefix=False)
|
||||
|
||||
Reference in New Issue
Block a user