teamy_windows/string/
utf8.rs

1use windows::Win32::Globalization::GetACP;
2
3/// https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
4pub const UTF8_CODEPAGE: u32 = 65001;
5
6pub fn is_system_utf8() -> bool {
7    unsafe { GetACP() == UTF8_CODEPAGE }
8}
9
10pub fn warn_if_utf8_not_enabled() {
11    if !is_system_utf8() {
12        tracing::warn!("The current system codepage is not UTF-8. This may cause '�' problems.");
13        tracing::warn!(
14            "See https://github.com/Azure/azure-cli/issues/22616#issuecomment-1147061949"
15        );
16        tracing::warn!(
17            "Control panel -> Clock and Region -> Region -> Administrative -> Change system locale -> Check Beta: Use Unicode UTF-8 for worldwide language support."
18        );
19    }
20}