Generalize locale checker to support more UTF-8 types (#623)
Signed-off-by: coleramos425 <colramos@amd.com>
This commit is contained in:
+18
-6
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user