Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions stm32CubeProg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,32 @@ check_getopt() {
esac
}

# Qt in STM32CubeProgrammer expects a UTF-8 locale on Linux/macOS.
ensure_utf8_locale() {
case "${UNAME_OS}" in
Linux* | Darwin*)
if command -v locale >/dev/null 2>&1; then
CHARMAP=$(LC_ALL='' LANG='' locale charmap 2>/dev/null || true)
case "${CHARMAP}" in
UTF-8 | utf8) ;;
*)
LOCALES_RES=$(locale -a 2>/dev/null || true)
if printf '%s\n' "${LOCALES_RES}" | grep -qi '^C\.UTF-8$'; then
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
elif printf '%s\n' "${LOCALES_RES}" | grep -qiE '^en_US\.(UTF-8|utf8)$'; then
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
fi
Comment on lines +143 to +150
;;
esac
fi
;;
esac
}

check_getopt
ensure_utf8_locale

# Check STM32CubeProgrammer cli availability
case "${UNAME_OS}" in
Expand Down