मैं इसके सीखने के चरण में हूं, इसलिए मुझे कुछ गलत होने पर सही करें।
- उपयोग विस्तृत अदालत, CIN, स्ट्रिंग के इतने पर संस्करणों और:
यह इस तरह लगता है एक तीन चरण की प्रक्रिया है। तो: wcout, wcin, wstring
- स्ट्रीम का उपयोग करने से पहले इसे यूनिकोड-अनुकूल मोड में सेट करें।
- यूनिकोड-सक्षम फ़ॉन्ट का उपयोग करने के लिए लक्षित कंसोल को कॉन्फ़िगर करें।
अब आप उन funky åäös को रॉक करने में सक्षम होना चाहिए।
उदाहरण:
#include <iostream>
#include <string>
#include <io.h>
// We only need one mode definition in this example, but it and several other
// reside in the header file fcntl.h.
#define _O_WTEXT 0x10000 /* file mode is UTF16 (translated) */
// Possibly useful if we want UTF-8
//#define _O_U8TEXT 0x40000 /* file mode is UTF8 no BOM (translated) */
void main(void)
{
// To be able to write UFT-16 to stdout.
_setmode(_fileno(stdout), _O_WTEXT);
// To be able to read UTF-16 from stdin.
_setmode(_fileno(stdin), _O_WTEXT);
wchar_t* hallå = L"Hallå, värld!";
std::wcout << hallå << std::endl;
// It's all Greek to me. Go UU!
std::wstring etabetapi = L"η β π";
std::wcout << etabetapi << std::endl;
std::wstring myInput;
std::wcin >> myInput;
std:: wcout << myInput << L" has " << myInput.length() << L" characters." << std::endl;
// This character won't show using Consolas or Lucida Console
std::wcout << L"♔" << std::endl;
}
स्रोत
2013-03-16 12:26:34
अपने कंसोल फ़ॉन्ट क्या है? जांचने के लिए बस CMD.EXE का उपयोग करें। यह विंडोज संस्करण से संस्करण के लिए अलग है और अनुकूलित किया जा सकता है। – MSalters