Correct.
The wide streams must translate to ASCII in that situation with no
selected locale, i.e. with the default "C" locale.
> It doesn't work for all
> non-ASCII characters, which is hardly surprising. A quick test with
> Norwegian letters "å", "ø" and "æ" resulted in "?", "?" and "ae".
>
> The simple answer, at least in the *nix world, is to drop "wchar_t"
> completely and forget that disaster ever existed.
Agreed, including the qualification.
> #include <iostream>
> using namespace std;
>
> int main()
> {
> const char russian[] = "Привет мир"; //Russian for "hello, world"
I would just write
const auto& russian = "Привет мир"; //Russian for "hello, world"
... preserving the length information, and not relying on the compiler
to optimize away the copying, where the technically redundant `const` is
for clarity and supports fast visual scanning of code.
In particular this supports forming a `constexpr stringview`.
> cout << russian << endl;
>
> for (const char_t &x : russian)
> cout << x << L", ";
> cout << endl;
> }
>
> As long as you have UTF8 locales and fonts (and you'd need an ancient
> setup, or a very limited one, not to have them), you'll get the right
> output.
>
>
> What I have learned from all this, is that "мир" ("mir") means "world"
> as well as "peace". I find that an interesting linguistic titbit.
And, a space station. :-o
I think in these troublesome times (North Stream 2 etc., not to mention
Hunter Biden's non-doings in Ukraine) it's worth mentioning, also a
little off-topic, that, according to Wikipedia, Russia supported the
American Revolution, and not just by later selling them Alaska. If not
for Russia the American Revolution would IMO have failed, i.e., Russia
helped to /create/ the United States. The first quoted sentence below is
at best opinion presented as fact (unlike my
opinion-presented-as-opinion), using words with negative connotations
(again unlike mine), and it says a lot that it's there uncontested in
Wikipedia, but anyway:
<<
Catherine the Great, a Russian empress who ruled from 1762–1796, played
a modest role in the American Revolutionary War through her politicking
with other European heads of state. Initially, the tsarina took a keen
interest in the American struggle because it affected "English and
European politics" and frankly believed that Britain was to blame for
the conflict. She held a negative opinion of King George and his
diplomats, often treating them with contempt. Nonetheless, the British
crown still formally requested 20,000 troops in 1775 and sought an
alliance.[20] She refused both pleas. Upon Spain's entry into the war,
Britain once again turned to the Russian Empire, but this time, the
English hoped for naval support. Catherine II once again ignored the
British requests.
Perhaps Catherine the Great's greatest diplomatic contribution came from
the creation and proclamation of the First League of Armed Neutrality in
1780. This declaration of armed neutrality had several stipulations, but
three crucial ones: first, "that neutral ships may freely visit the
ports of belligerent Powers;" second, "that the goods of belligerent
Powers on neutral ships are permitted to pass without hindrance, with
the exception of war contraband;" and, third, "under the definition of a
blockaded port falls only a port into which entry is actually hampered
by naval forces." Most European nations agreed to these terms, but
Britain refused to recognize the arrangement because it undermined the
blockade, its most effective military strategy. After establishing a
league of neutral parties, Catherine the Great attempted to act as a
mediator between the United States and Britain by submitting a ceasefire
plan. During her attempts at mediation, though, the Battle of Yorktown
thwarted any hope of a peaceful and diplomatic solution to the American
Revolutionary War.
These negotiations were accompanied by political intrigue. In 1780,
during the period of Catherine II's mediating, Britain attempted to
bribe the Russian Empire into an alliance. London offered St. Petersburg
the island of Menorca if the Russians would agree to join the British in
the war. Despite the economic boost such an acquisition offered,
Catherine the Great refused this bribe and utilized it as an opportunity
to make George III a laughing–stock of the European powers.
>>
- Alf