如何使用Codeblock在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.
我在Internet上进行了搜索,以了解如何在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.
这篇关于如何使用Codeblock在C ++中编写阿拉伯字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!