在 C++ 中输入阿拉伯字符从 Windows 上的控制台应用程序

发布于 2024-09-26 07:34:13 字数 58 浏览 0 评论 0原文

是否有任何示例代码显示如何在 Windows 中的控制台应用程序上用 C++ 接受用户的阿拉伯语输入?

Is there any example Code showing How to accept Arabic Input from user in C++ on a console application, in windows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野鹿林 2024-10-03 07:34:13

我会尝试回答C++部分。您无法使用 cin 从控制台读取阿拉伯字符。然而,在 中,有一个预声明的 wcin 对象,其类型为 wistream - 宽字符输入流。并且您不应将输入读取到 string 中,而是读取到 wstring 中。

例如,

#include <iostream>
#include <string>
int main()
{
   std::wstring s;
   std::wcin >> s;
}

这是 C++ 部分,但问题仍然是您的操作系统是否允许在控制台窗口中使用宽字符。华泰

I'll try answer the C++ part. You cannot read arabic characters from console with cin. However in <iostream> there's a predeclared wcin object that is of type wistream - a wide-character input stream. And you should read an input not into string but into wstring.

e.g

#include <iostream>
#include <string>
int main()
{
   std::wstring s;
   std::wcin >> s;
}

This was the C++ part, however the question remains whether or not your OS allows wide characters in the console window. HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文