Generalize locale checker to support more UTF-8 types (#623)

Signed-off-by: coleramos425 <colramos@amd.com>
This commit is contained in:
Cole Ramos
2025-03-25 16:39:02 -05:00
committed by GitHub
parent 983f902fa0
commit 38c7dce84a
+18 -6
View File
@@ -1163,13 +1163,25 @@ def print_status(msg):
def set_locale_encoding():
try:
# Attempt to set the locale to 'C.UTF-8'
locale.setlocale(locale.LC_ALL, "C.UTF-8")
except locale.Error as error:
console_error(
"Please ensure that the 'C.UTF-8' locale is available on your system.",
exit=False,
)
console_error(error)
except locale.Error:
# If 'C.UTF-8' is not available, check if the current locale is UTF-8 based
current_locale = locale.getdefaultlocale()
if current_locale and "UTF-8" in current_locale[1]:
try:
locale.setlocale(locale.LC_ALL, current_locale[0])
except locale.Error as error:
console_error(
"Failed to set locale to the current UTF-8-based locale.",
exit=False,
)
console_error(error)
else:
console_error(
"Please ensure that a UTF-8-based locale is available on your system.",
exit=False,
)
def reverse_multi_index_df_pmc(final_df):