<p>What is the best way people have found to do String to Lower case / Upper case in C++?</p>

<p>The issue is complicated by the fact that C++ isn't an English only programming language. Is there a good multilingual method?</p>

[{'answer_id': 11502, 'author': 'Darren Kopp', 'author_id': 77, 'author_profile': 'https://Stackoverflow.com/users/77', 'pm_score': 6, 'selected': True, 'text': '<pre><code>#include &lt;algorithm&gt;\nstd::string data = "Abc";\nstd::transform(data.begin(), data.end(), data.begin(), ::toupper);\n</code></pre>\n\n<p><a href="http://notfaq.wordpress.com/2007/08/04/cc-convert-string-to-upperlower-case/" rel="noreferrer">http://notfaq.wordpress.com/2007/08/04/cc-convert-string-to-upperlower-case/</a></p>\n\n<p>Also, CodeProject article for common string methods: <a href="http://www.codeproject.com/KB/stl/STL_string_util.aspx" rel="noreferrer">http://www.codeproject.com/KB/stl/STL_string_util.aspx</a></p>\n'}, {'answer_id': 13341, 'author': 'Rob Thomas', 'author_id': 803, 'author_profile': 'https://Stackoverflow.com/users/803', 'pm_score': 2, 'selected': False, 'text': '<p>You should also review <a href="https://stackoverflow.com/questions/11635/case-insensitive-string-comparison-in-c">this question</a>.  Basically the problem is that the standard C/C++ libraries weren\'t built to handle Unicode data, so you will have to look to other libraries.  </p>\n\n<p>This may change as the C++ standard is updated.  I know the next compiler from Borland (CodeGear) will have Unicode support, and I would guess Microsoft\'s C++ compiler will have, or already has string libraries that support Unicode.</p>\n'}, {'answer_id': 13624, 'author': 'Steve Gury', 'author_id': 1578, 'author_profile': 'https://Stackoverflow.com/users/1578', 'pm_score': 2, 'selected': False, 'text': '<p>As Darren told you, the easiest method is to use std::transform. </p>\n\n<p>But beware that in some language, like German for instance, there isn\'t always a one to one mapping between lower and uppercase. The "esset" lowercase character (look like the Greek character beta) is transformed to "SS" in uppercase.</p>\n'}, {'answer_id': 21395, 'author': 'Nic Strong', 'author_id': 2281, 'author_profile': 'https://Stackoverflow.com/users/2281', 'pm_score': 4, 'selected': False, 'text': '<pre><code>&gt; std::string data = “Abc”; \n&gt; std::transform(data.begin(), data.end(), data.begin(), ::toupper);\n</code></pre>\n\n<p>This will work, but this will use the standard "C" locale. You can use facets if you need to get a tolower for another locale. The above code using facets would be:</p>\n\n<pre><code>locale loc("");\nconst ctype&lt;char&gt;&amp; ct = use_facet&lt;ctype&lt;char&gt; &gt;(loc);\ntransform(str.begin(), str.end(), std::bind1st(std::mem_fun(&amp;ctype&lt;char&gt;::tolower), &amp;ct));\n</code></pre>\n'}, {'answer_id': 28849, 'author': 'axs6791', 'author_id': 3081, 'author_profile': 'https://Stackoverflow.com/users/3081', 'pm_score': 0, 'selected': False, 'text': '<p>What Steve says is right, but I guess that if your code had to support several languages, you could have a factory method that encapsulates a set of methods that do the relevant toUpper or toLower based on that language.</p>\n'}, {'answer_id': 1724567, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>For copy-pasters hoping to use Nic Strong\'s answer, note the spelling error in "use_factet" and the missing third parameter to std::transform:</p>\n\n<pre><code>locale loc("");\nconst ctype&lt;char&gt;&amp; ct = use_factet&lt;ctype&lt;char&gt; &gt;(loc);\ntransform(str.begin(), str.end(), std::bind1st(std::mem_fun(&amp;ctype&lt;char&gt;::tolower), &amp;ct));\n</code></pre>\n\n<p>should be</p>\n\n<pre><code>locale loc("");\nconst ctype&lt;char&gt;&amp; ct = use_facet&lt;ctype&lt;char&gt; &gt;(loc);\ntransform(str.begin(), str.end(), str.begin(), std::bind1st(std::mem_fun(&amp;ctype&lt;char&gt;::tolower), &amp;ct));\n</code></pre>\n'}, {'answer_id': 4336156, 'author': 'yasouser', 'author_id': 338913, 'author_profile': 'https://Stackoverflow.com/users/338913', 'pm_score': 2, 'selected': False, 'text': '<p>If you have Boost, then it has the simplest way. Have a look at <a href="http://www.boost.org/doc/libs/1_45_0/doc/html/string_algo/usage.html#id2570604" rel="nofollow">to_upper()/to_lower() in Boost string algorithms</a>.</p>\n'}, {'answer_id': 15151222, 'author': 'NoOne', 'author_id': 964053, 'author_profile': 'https://Stackoverflow.com/users/964053', 'pm_score': 1, 'selected': False, 'text': '<p>I have found a way to convert the case of unicode (and multilingual) characters, but you need to know/find (somehow) the locale of the character:</p>\n\n<pre><code>#include &lt;locale.h&gt;\n\n_locale_t locale = _create_locale(LC_CTYPE, "Greek");\nAfxMessageBox((CString)""+(TCHAR)_totupper_l(_T(\'α\'), locale));\n_free_locale(locale);\n</code></pre>\n\n<p>I haven\'t found a way to do that yet... I someone knows how, let me know.</p>\n\n<p>Setting locale to NULL doesn\'t work...</p>\n'}, {'answer_id': 21387775, 'author': 'James Oravec', 'author_id': 1190934, 'author_profile': 'https://Stackoverflow.com/users/1190934', 'pm_score': 1, 'selected': False, 'text': '<p>The <code>VCL</code> has a <code>SysUtils.hpp</code> which has <code>LowerCase(unicodeStringVar)</code> and <code>UpperCase(unicodeStringVar)</code> which might work for you. I use this in C++ Builder 2009.</p>\n'}, {'answer_id': 64410355, 'author': 'Joma', 'author_id': 3158594, 'author_profile': 'https://Stackoverflow.com/users/3158594', 'pm_score': 0, 'selected': False, 'text': '<p>Based on <a href="https://stackoverflow.com/users/1689664/kyle-the-hacker">Kyle_the_hacker\'s</a> -----&gt; <a href="https://stackoverflow.com/a/17993266/3158594">answer</a> with my extras.</p>\n<h1>Ubuntu</h1>\n<p>In terminal\nList all locales<br />\n<code>locale -a</code></p>\n<p>Install all locales<br />\n<code>sudo apt-get install -y locales locales-all</code></p>\n<p>Compile main.cpp<br />\n<code>$ g++ main.cpp </code></p>\n<p>Run compiled program<br />\n<code>$ ./a.out </code></p>\n<p><strong>Results</strong></p>\n<pre><code>Zoë Saldaña played in La maldición del padre Cardona. ëèñ αω óóChloë\nZoë Saldaña played in La maldición del padre Cardona. ëèñ αω óóChloë\nZOË SALDAÑA PLAYED IN LA MALDICIÓN DEL PADRE CARDONA. ËÈÑ ΑΩ ÓÓCHLOË\nZOË SALDAÑA PLAYED IN LA MALDICIÓN DEL PADRE CARDONA. ËÈÑ ΑΩ ÓÓCHLOË\nzoë saldaña played in la maldición del padre cardona. ëèñ αω óóchloë\nzoë saldaña played in la maldición del padre cardona. ëèñ αω óóchloë\n</code></pre>\n<p><a href="https://i.stack.imgur.com/9KdHH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9KdHH.png" alt="Ubuntu Linux - WSL from VSCODE" /></a></p>\n<p><a href="https://i.stack.imgur.com/wRHnw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wRHnw.png" alt="Ubuntu Linux - WSL" /></a></p>\n<h1>Windows</h1>\n<p>In cmd run VCVARS developer tools<br />\n<code>&quot;C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat&quot; </code></p>\n<p>Compile main.cpp<br />\n<code>&gt; cl /EHa main.cpp  /D &quot;_DEBUG&quot; /D &quot;_CONSOLE&quot; /D &quot;_UNICODE&quot; /D &quot;UNICODE&quot; /std:c++17  /DYNAMICBASE &quot;kernel32.lib&quot; &quot;user32.lib&quot; &quot;gdi32.lib&quot; &quot;winspool.lib&quot; &quot;comdlg32.lib&quot; &quot;advapi32.lib&quot; &quot;shell32.lib&quot; &quot;ole32.lib&quot; &quot;oleaut32.lib&quot; &quot;uuid.lib&quot; &quot;odbc32.lib&quot; &quot;odbccp32.lib&quot;  /MTd</code></p>\n<pre><code>Compilador de optimización de C/C++ de Microsoft (R) versión 19.27.29111 para x64\n(C) Microsoft Corporation. Todos los derechos reservados.\n\nmain.cpp\nMicrosoft (R) Incremental Linker Version 14.27.29111.0\nCopyright (C) Microsoft Corporation.  All rights reserved.\n\n/out:main.exe\nmain.obj\nkernel32.lib\nuser32.lib\ngdi32.lib\nwinspool.lib\ncomdlg32.lib\nadvapi32.lib\nshell32.lib\nole32.lib\noleaut32.lib\nuuid.lib\nodbc32.lib\nodbccp32.lib\n</code></pre>\n<p>Run main.exe<br />\n<code>&gt;main.exe</code></p>\n<p><strong>Results</strong></p>\n<pre><code>Zoë Saldaña played in La maldición del padre Cardona. ëèñ αω óóChloë\nZoë Saldaña played in La maldición del padre Cardona. ëèñ αω óóChloë\nZOË SALDAÑA PLAYED IN LA MALDICIÓN DEL PADRE CARDONA. ËÈÑ ΑΩ ÓÓCHLOË\nZOË SALDAÑA PLAYED IN LA MALDICIÓN DEL PADRE CARDONA. ËÈÑ ΑΩ ÓÓCHLOË\nzoë saldaña played in la maldición del padre cardona. ëèñ αω óóchloë\nzoë saldaña played in la maldición del padre cardona. ëèñ αω óóchloë\n</code></pre>\n<p><a href="https://i.stack.imgur.com/c1Kpn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c1Kpn.png" alt="Windows" /></a></p>\n<h2>The code - main.cpp</h2>\n<blockquote>\n<p><strong>This code was only tested on Windows x64 and Ubuntu Linux x64.</strong></p>\n</blockquote>\n<pre class="lang-cpp prettyprint-override"><code>/*\n * Filename: c:\\Users\\x\\Cpp\\main.cpp\n * Path: c:\\Users\\x\\Cpp\n * Filename: /home/x/Cpp/main.cpp\n * Path: /home/x/Cpp\n * Created Date: Saturday, October 17th 2020, 10:43:31 pm\n * Author: Joma\n *\n * No Copyright 2020\n */\n\n\n#include &lt;iostream&gt;\n#include &lt;set&gt;\n#include &lt;string&gt;\n#include &lt;locale&gt;\n\n// WINDOWS\n#if (_WIN32)\n#include &lt;Windows.h&gt;\n#include &lt;conio.h&gt;\n#define WINDOWS_PLATFORM 1\n#define DLLCALL STDCALL\n#define DLLIMPORT _declspec(dllimport)\n#define DLLEXPORT _declspec(dllexport)\n#define DLLPRIVATE\n#define NOMINMAX\n\n//EMSCRIPTEN\n#elif defined(__EMSCRIPTEN__)\n#include &lt;emscripten/emscripten.h&gt;\n#include &lt;emscripten/bind.h&gt;\n#include &lt;unistd.h&gt;\n#include &lt;termios.h&gt;\n#define EMSCRIPTEN_PLATFORM 1\n#define DLLCALL\n#define DLLIMPORT\n#define DLLEXPORT __attribute__((visibility(&quot;default&quot;)))\n#define DLLPRIVATE __attribute__((visibility(&quot;hidden&quot;)))\n\n// LINUX - Ubuntu, Fedora, , Centos, Debian, RedHat\n#elif (__LINUX__ || __gnu_linux__ || __linux__ || __linux || linux)\n#define LINUX_PLATFORM 1\n#include &lt;unistd.h&gt;\n#include &lt;termios.h&gt;\n#define DLLCALL CDECL\n#define DLLIMPORT\n#define DLLEXPORT __attribute__((visibility(&quot;default&quot;)))\n#define DLLPRIVATE __attribute__((visibility(&quot;hidden&quot;)))\n#define CoTaskMemAlloc(p) malloc(p)\n#define CoTaskMemFree(p) free(p)\n\n//ANDROID\n#elif (__ANDROID__ || ANDROID)\n#define ANDROID_PLATFORM 1\n#define DLLCALL\n#define DLLIMPORT\n#define DLLEXPORT __attribute__((visibility(&quot;default&quot;)))\n#define DLLPRIVATE __attribute__((visibility(&quot;hidden&quot;)))\n\n//MACOS\n#elif defined(__APPLE__)\n#include &lt;unistd.h&gt;\n#include &lt;termios.h&gt;\n#define DLLCALL\n#define DLLIMPORT\n#define DLLEXPORT __attribute__((visibility(&quot;default&quot;)))\n#define DLLPRIVATE __attribute__((visibility(&quot;hidden&quot;)))\n#include &quot;TargetConditionals.h&quot;\n#if TARGET_OS_IPHONE &amp;&amp; TARGET_IPHONE_SIMULATOR\n#define IOS_SIMULATOR_PLATFORM 1\n#elif TARGET_OS_IPHONE\n#define IOS_PLATFORM 1\n#elif TARGET_OS_MAC\n#define MACOS_PLATFORM 1\n#else\n\n#endif\n\n#endif\n\n\n\ntypedef std::string String;\ntypedef std::wstring WString;\n\n#define EMPTY_STRING u8&quot;&quot;s\n#define EMPTY_WSTRING L&quot;&quot;s\n\nusing namespace std::literals::string_literals;\n\nclass Strings\n{\npublic:\n    static String WideStringToString(const WString&amp; wstr)\n    {\n        if (wstr.empty())\n        {\n            return String();\n        }\n        size_t pos;\n        size_t begin = 0;\n        String ret;\n\n#if WINDOWS_PLATFORM\n        int size;\n        pos = wstr.find(static_cast&lt;wchar_t&gt;(0), begin);\n        while (pos != WString::npos &amp;&amp; begin &lt; wstr.length())\n        {\n            WString segment = WString(&amp;wstr[begin], pos - begin);\n            size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, &amp;segment[0], segment.size(), NULL, 0, NULL, NULL);\n            String converted = String(size, 0);\n            WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, &amp;segment[0], segment.size(), &amp;converted[0], converted.size(), NULL, NULL);\n            ret.append(converted);\n            ret.append({ 0 });\n            begin = pos + 1;\n            pos = wstr.find(static_cast&lt;wchar_t&gt;(0), begin);\n        }\n        if (begin &lt;= wstr.length())\n        {\n            WString segment = WString(&amp;wstr[begin], wstr.length() - begin);\n            size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, &amp;segment[0], segment.size(), NULL, 0, NULL, NULL);\n            String converted = String(size, 0);\n            WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, &amp;segment[0], segment.size(), &amp;converted[0], converted.size(), NULL, NULL);\n            ret.append(converted);\n        }\n#elif LINUX_PLATFORM || MACOS_PLATFORM || EMSCRIPTEN_PLATFORM\n        size_t size;\n        pos = wstr.find(static_cast&lt;wchar_t&gt;(0), begin);\n        while (pos != WString::npos &amp;&amp; begin &lt; wstr.length())\n        {\n            WString segment = WString(&amp;wstr[begin], pos - begin);\n            size = wcstombs(nullptr, segment.c_str(), 0);\n            String converted = String(size, 0);\n            wcstombs(&amp;converted[0], segment.c_str(), converted.size());\n            ret.append(converted);\n            ret.append({ 0 });\n            begin = pos + 1;\n            pos = wstr.find(static_cast&lt;wchar_t&gt;(0), begin);\n        }\n        if (begin &lt;= wstr.length())\n        {\n            WString segment = WString(&amp;wstr[begin], wstr.length() - begin);\n            size = wcstombs(nullptr, segment.c_str(), 0);\n            String converted = String(size, 0);\n            wcstombs(&amp;converted[0], segment.c_str(), converted.size());\n            ret.append(converted);\n        }\n#else\n        static_assert(false, &quot;Unknown Platform&quot;);\n#endif\n        return ret;\n    }\n\n    static WString StringToWideString(const String&amp; str)\n    {\n        if (str.empty())\n        {\n            return WString();\n        }\n\n        size_t pos;\n        size_t begin = 0;\n        WString ret;\n#ifdef WINDOWS_PLATFORM\n        int size = 0;\n        pos = str.find(static_cast&lt;char&gt;(0), begin);\n        while (pos != std::string::npos) {\n            std::string segment = std::string(&amp;str[begin], pos - begin);\n            std::wstring converted = std::wstring(segment.size() + 1, 0);\n            size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, &amp;segment[0], segment.size(), &amp;converted[0], converted.length());\n            converted.resize(size);\n            ret.append(converted);\n            ret.append({ 0 });\n            begin = pos + 1;\n            pos = str.find(static_cast&lt;char&gt;(0), begin);\n        }\n        if (begin &lt; str.length()) {\n            std::string segment = std::string(&amp;str[begin], str.length() - begin);\n            std::wstring converted = std::wstring(segment.size() + 1, 0);\n            size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, segment.c_str(), segment.size(), &amp;converted[0], converted.length());\n            converted.resize(size);\n            ret.append(converted);\n        }\n\n#elif LINUX_PLATFORM || MACOS_PLATFORM || EMSCRIPTEN_PLATFORM\n        size_t size;\n        pos = str.find(static_cast&lt;char&gt;(0), begin);\n        while (pos != String::npos)\n        {\n            String segment = String(&amp;str[begin], pos - begin);\n            WString converted = WString(segment.size(), 0);\n            size = mbstowcs(&amp;converted[0], &amp;segment[0], converted.size());\n            converted.resize(size);\n            ret.append(converted);\n            ret.append({ 0 });\n            begin = pos + 1;\n            pos = str.find(static_cast&lt;char&gt;(0), begin);\n        }\n        if (begin &lt; str.length())\n        {\n            String segment = String(&amp;str[begin], str.length() - begin);\n            WString converted = WString(segment.size(), 0);\n            size = mbstowcs(&amp;converted[0], &amp;segment[0], converted.size());\n            converted.resize(size);\n            ret.append(converted);\n        }\n#else\n        static_assert(false, &quot;Unknown Platform&quot;);\n#endif\n        return ret;\n    }\n\n\n    static WString ToUpper(const WString&amp; data)\n    {\n        WString result = data;\n        auto&amp; f = std::use_facet&lt;std::ctype&lt;wchar_t&gt;&gt;(std::locale());\n\n        f.toupper(&amp;result[0], &amp;result[0] + result.size());\n        return result;\n    }\n\n    static String  ToUpper(const String&amp; data)\n    {\n        return WideStringToString(ToUpper(StringToWideString(data)));\n    }\n\n    static WString ToLower(const WString&amp; data)\n    {\n        WString result = data;\n        auto&amp; f = std::use_facet&lt;std::ctype&lt;wchar_t&gt;&gt;(std::locale());\n        f.tolower(&amp;result[0], &amp;result[0] + result.size());\n        return result;\n    }\n\n    static String ToLower(const String&amp; data)\n    {\n        return WideStringToString(ToLower(StringToWideString(data)));\n    }\n\n};\n\nenum class ConsoleTextStyle\n{\n    DEFAULT = 0,\n    BOLD = 1,\n    FAINT = 2,\n    ITALIC = 3,\n    UNDERLINE = 4,\n    SLOW_BLINK = 5,\n    RAPID_BLINK = 6,\n    REVERSE = 7,\n};\n\nenum class ConsoleForeground\n{\n    DEFAULT = 39,\n    BLACK = 30,\n    DARK_RED = 31,\n    DARK_GREEN = 32,\n    DARK_YELLOW = 33,\n    DARK_BLUE = 34,\n    DARK_MAGENTA = 35,\n    DARK_CYAN = 36,\n    GRAY = 37,\n    DARK_GRAY = 90,\n    RED = 91,\n    GREEN = 92,\n    YELLOW = 93,\n    BLUE = 94,\n    MAGENTA = 95,\n    CYAN = 96,\n    WHITE = 97\n};\n\nenum class ConsoleBackground\n{\n    DEFAULT = 49,\n    BLACK = 40,\n    DARK_RED = 41,\n    DARK_GREEN = 42,\n    DARK_YELLOW = 43,\n    DARK_BLUE = 44,\n    DARK_MAGENTA = 45,\n    DARK_CYAN = 46,\n    GRAY = 47,\n    DARK_GRAY = 100,\n    RED = 101,\n    GREEN = 102,\n    YELLOW = 103,\n    BLUE = 104,\n    MAGENTA = 105,\n    CYAN = 106,\n    WHITE = 107\n};\n\nclass Console\n{\nprivate:\n    static void EnableVirtualTermimalProcessing()\n    {\n#if defined WINDOWS_PLATFORM\n        HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);\n        DWORD dwMode = 0;\n        GetConsoleMode(hOut, &amp;dwMode);\n        if (!(dwMode &amp; ENABLE_VIRTUAL_TERMINAL_PROCESSING))\n        {\n            dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;\n            SetConsoleMode(hOut, dwMode);\n        }\n#endif\n    }\n\n    static void ResetTerminalFormat()\n    {\n        std::cout &lt;&lt; u8&quot;\\033[0m&quot;;\n    }\n\n    static void SetVirtualTerminalFormat(ConsoleForeground foreground, ConsoleBackground background, std::set&lt;ConsoleTextStyle&gt; styles)\n    {\n        String format = u8&quot;\\033[&quot;;\n        format.append(std::to_string(static_cast&lt;int&gt;(foreground)));\n        format.append(u8&quot;;&quot;);\n        format.append(std::to_string(static_cast&lt;int&gt;(background)));\n        if (styles.size() &gt; 0)\n        {\n            for (auto it = styles.begin(); it != styles.end(); ++it)\n            {\n                format.append(u8&quot;;&quot;);\n                format.append(std::to_string(static_cast&lt;int&gt;(*it)));\n            }\n        }\n        format.append(u8&quot;m&quot;);\n        std::cout &lt;&lt; format;\n    }\npublic:\n    static void Clear()\n    {\n\n#ifdef WINDOWS_PLATFORM\n        std::system(u8&quot;cls&quot;);\n#elif LINUX_PLATFORM || defined MACOS_PLATFORM\n        std::system(u8&quot;clear&quot;);\n#elif EMSCRIPTEN_PLATFORM\n        emscripten::val::global()[&quot;console&quot;].call&lt;void&gt;(u8&quot;clear&quot;);\n#else\n        static_assert(false, &quot;Unknown Platform&quot;);\n#endif\n    }\n\n    static void Write(const String&amp; s, ConsoleForeground foreground = ConsoleForeground::DEFAULT, ConsoleBackground background = ConsoleBackground::DEFAULT, std::set&lt;ConsoleTextStyle&gt; styles = {})\n    {\n#ifndef EMSCRIPTEN_PLATFORM\n        EnableVirtualTermimalProcessing();\n        SetVirtualTerminalFormat(foreground, background, styles);\n#endif\n        String str = s;\n#ifdef WINDOWS_PLATFORM\n        WString unicode = Strings::StringToWideString(str);\n        WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), unicode.c_str(), static_cast&lt;DWORD&gt;(unicode.length()), nullptr, nullptr);\n#elif defined LINUX_PLATFORM || defined MACOS_PLATFORM || EMSCRIPTEN_PLATFORM\n        std::cout &lt;&lt; str;\n#else\n        static_assert(false, &quot;Unknown Platform&quot;);\n#endif\n\n#ifndef EMSCRIPTEN_PLATFORM\n        ResetTerminalFormat();\n#endif\n    }\n\n    static void WriteLine(const String&amp; s, ConsoleForeground foreground = ConsoleForeground::DEFAULT, ConsoleBackground background = ConsoleBackground::DEFAULT, std::set&lt;ConsoleTextStyle&gt; styles = {})\n    {\n        Write(s, foreground, background, styles);\n        std::cout &lt;&lt; std::endl;\n    }\n\n    static void Write(const WString&amp; s, ConsoleForeground foreground = ConsoleForeground::DEFAULT, ConsoleBackground background = ConsoleBackground::DEFAULT, std::set&lt;ConsoleTextStyle&gt; styles = {})\n    {\n#ifndef EMSCRIPTEN_PLATFORM\n        EnableVirtualTermimalProcessing();\n        SetVirtualTerminalFormat(foreground, background, styles);\n#endif\n        WString str = s;\n\n#ifdef WINDOWS_PLATFORM\n        WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), str.c_str(), static_cast&lt;DWORD&gt;(str.length()), nullptr, nullptr);\n#elif LINUX_PLATFORM || MACOS_PLATFORM || EMSCRIPTEN_PLATFORM\n        std::cout &lt;&lt; Strings::WideStringToString(str);\n#else\n        static_assert(false, &quot;Unknown Platform&quot;);\n#endif\n\n#ifndef EMSCRIPTEN_PLATFORM\n        ResetTerminalFormat();\n#endif\n    }\n\n    static void WriteLine(const WString&amp; s, ConsoleForeground foreground = ConsoleForeground::DEFAULT, ConsoleBackground background = ConsoleBackground::DEFAULT, std::set&lt;ConsoleTextStyle&gt; styles = {})\n    {\n        Write(s, foreground, background, styles);\n        std::cout &lt;&lt; std::endl;\n    }\n\n    static void WriteLine()\n    {\n        std::cout &lt;&lt; std::endl;\n    }\n\n    static void Pause()\n    {\n        char c;\n        do\n        {\n            c = getchar();\n            std::cout &lt;&lt; &quot;Press Key &quot; &lt;&lt; std::endl;\n        } while (c != 64);\n        std::cout &lt;&lt; &quot;KeyPressed&quot; &lt;&lt; std::endl;\n    }\n\n    static int PauseAny(bool printWhenPressed = false, ConsoleForeground foreground = ConsoleForeground::DEFAULT, ConsoleBackground background = ConsoleBackground::DEFAULT, std::set&lt;ConsoleTextStyle&gt; styles = {})\n    {\n        int ch;\n#ifdef WINDOWS_PLATFORM\n        ch = _getch();\n#elif LINUX_PLATFORM || MACOS_PLATFORM || EMSCRIPTEN_PLATFORM\n        struct termios oldt, newt;\n        tcgetattr(STDIN_FILENO, &amp;oldt);\n        newt = oldt;\n        newt.c_lflag &amp;= ~(ICANON | ECHO);\n        tcsetattr(STDIN_FILENO, TCSANOW, &amp;newt);\n        ch = getchar();\n        tcsetattr(STDIN_FILENO, TCSANOW, &amp;oldt);\n#else\n        static_assert(false, &quot;Unknown Platform&quot;);\n#endif\n        if (printWhenPressed)\n        {\n            Console::Write(String(1, ch), foreground, background, styles);\n        }\n        return ch;\n    }\n};\n\n\n\nint main()\n{\n    std::locale::global(std::locale(u8&quot;en_US.UTF-8&quot;));\n    String dataStr = u8&quot;Zoë Saldaña played in La maldición del padre Cardona. ëèñ αω óóChloë&quot;;\n    WString dataWStr = L&quot;Zoë Saldaña played in La maldición del padre Cardona. ëèñ αω óóChloë&quot;;\n    std::string locale = u8&quot;&quot;;\n    //std::string locale = u8&quot;de_DE.UTF-8&quot;;\n    //std::string locale = u8&quot;en_US.UTF-8&quot;;\n    Console::WriteLine(dataStr);\n    Console::WriteLine(dataWStr);\n    dataStr = Strings::ToUpper(dataStr);\n    dataWStr = Strings::ToUpper(dataWStr);\n    Console::WriteLine(dataStr);\n    Console::WriteLine(dataWStr);\n    dataStr = Strings::ToLower(dataStr);\n    dataWStr = Strings::ToLower(dataWStr);\n    Console::WriteLine(dataStr);\n    Console::WriteLine(dataWStr);\n    \n    \n    Console::WriteLine(u8&quot;Press any key to exit&quot;s, ConsoleForeground::DARK_GRAY);\n    Console::PauseAny();\n\n    return 0;\n}\n\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/11491', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1366/']