Home > Backend Development > C++ > What is the Windows Equivalent of the 'en_US.UTF-8' Locale?

What is the Windows Equivalent of the 'en_US.UTF-8' Locale?

Linda Hamilton
Release: 2024-12-27 08:58:10
Original
831 people have browsed it

What is the Windows Equivalent of the

Windows equivalent for en_US.UTF-8 locale

In programming, setting the locale is crucial for handling text input and output in the correct language and format. If you're porting code from another platform that specifies the "en_US.UTF-8" locale, you may wonder what its Windows equivalent is.

Historically, UTF-8 wasn't supported as a system locale in Windows due to compatibility concerns. However, Microsoft has gradually introduced UTF-8 support.

To enable UTF-8 locale support in Windows:

  1. Windows 10 build 17035 and later: Go to Region settings and enable "Use Unicode UTF-8 for worldwide language support." Then, use setlocale() with ".utf8" as the code page.
  2. Windows prior to 10: Use app-local deployment or statically link with version 17134 of the Windows SDK.
  3. Windows 10 build 17134 and later (2019): Use the "/execution-charset:utf-8" option when compiling with MSVC or set the ActiveCodePage property in appxmanifest.

Once UTF-8 support is enabled, you can use setlocale() as you would on other platforms, specifying "en_US.UTF-8" as the desired locale. Notably, this ensures that text input and output will be handled using the UTF-8 encoding, which supports a wide range of characters.

The above is the detailed content of What is the Windows Equivalent of the 'en_US.UTF-8' Locale?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template