locale and system laungues

时间:2024-10-17 13:35:50

In computing, a locale is a set of parameters that defines the user's language, region and any special variant preferences that the user wants to see in their user interface.
Usually a locale identifier consists of at least a language identifier and a region identifier.
on windows, use codepage instead of locale;
(narrowly speaking, locale decides the format how to show symbols like dollar and date, related to region;language enable and decide the way fonts are shown)

winodows use UTF-16 as the internal encoding for string literals, Unix-like system use UTF-8;
we can enforce windows to encode/decode strings with UTF-8;
before input a char, we should first choose an input language, so that keys can be convert to the char we want;
if bytes array of string A (encoded in UTF-16) is \x33\x44\x55, if we pass UTF-8 version bytes array of same string "\x33\x44\x56\x55", a win function can't find sting A;
language pack contains fonts to be used.
copy an string is copying a list of fonts?
u"charssss" in c++ means that this array is encoded in one implementation of Unicode? like utf-8 or utf-16, and its impiler-dependent.

locale and system laungues

example:

#include<iostream>
#include<string>
#include<codecvt>
using namespace std; int main()
{
char d1[] = u8"\xE6\x8E\x96";
char d2= u8"中国银行";
char16_t d3[] = u"中国银行";
string d4 = wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t>{}.to_bytes(d3);
cout << d1 << endl;
cout << d2 << endl;
wcout << d3 << endl;
cout <<d4 << endl;
}