如何使用代码块在 C++ 中编写阿拉伯字符串? [英] How can i write arabic string in C++ using Codeblocks?
问题描述
有人能告诉我如何用 C++ 写一个阿拉伯字符串吗??, 我正在使用代码块.
Could someone tell me how can I write an arabic string in C++ ?? , I am using Codeblocks.
我在互联网上搜索了所有内容以查看如何将阿拉伯字符串放入 C++ 代码中,但我没有找到任何内容
I searched all over the internet to see how can I put an arabic string in a c++ code but I didn't reach anything
推荐答案
有多种类型的字符串文字可用于 C++.虽然最常见的类型,窄多字节字符串文字,看起来像这样:
There are multiple types of string literals available for use in C++. While the most common type, the narrow multibyte string literal, looks like this:
auto myliteral = "";
还有其他.
具体来说,您可能正在寻找的是 utf-8 字符串文字,如下所示:
specifically, the one you might be looking for is the utf-8 string literal, written like this:
auto myutf8literal = u8"عربي";
基本字符串字面量的所有变体都带有一些字符组合:
all variations on the basic string literal are prepended with some combination of characters:
// ex. description storage
L""; // wide string literal wchar_t[]
u8""; // utf-8 encoded string literal char[]
u""; // utf-16 encoded string literal char16_t[]
U""; // utf-32 encoded string literal char32_t[]
R"delim()delim";
// raw string literal, modifier to indicate no escapes in string
// can be combined with any of the above string literal types
并且它们中的大多数可以容纳比基本字符串文字更多种类的字符.u8
、u
和 U
持有 unicode 字符集,这是一个相当庞大的字符集.
and most of them can hold a far greater variety of characters than the basic string literal. u8
, u
and U
hold the unicode character set, which is a rather massive set of characters.
您应该注意的是,在具有最小显示功能的环境中显示此字符串,而不是简单地写入文件,会引入额外的复杂性.例如:Windows 控制台在其可以显示的字符方面受到严重限制,并使用称为 代码页的内容 决定如何显示某些字符.它确实有一个 utf-8 代码页,但似乎是 一些问题.
Something you should be aware of is that displaying this string in environments with minimal display capabilities, rather than simply writing to a file, is going to introduce additional complications. As an example: the Windows console is heavily limited in which characters it can display, and uses something called a code page to decide how to display certain characters. It does have a utf-8 code page, though there appear to be some issues with it.
有关在 Linux 上处理阿拉伯语控制台输出的详细信息,请查看@cup 的回答.
For details on dealing with Arabic console output on Linux, look at @cup's answer.
这篇关于如何使用代码块在 C++ 中编写阿拉伯字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!