How to output non-English string literals in c++?

Brian Grasso 41 Reputation points
2021-02-08T09:03:37.237+00:00

I am working on a desktop console application that requires the use of non-English characters (Hebrew).

I have come to understand that building a Multi-Language User Interface is required to handle the output. When I attempted to follow the instruction for building a MUI from the Microsoft Learn references (Adding Multilingual User Interface Support to an Application - Win32 apps | Microsoft Learn) I encountered a number of issues. Primarily, upon building the script provided, I got these errors: E1696, E0065, and C1083 (stdafx.h: No such file or directory). I thought I was running the required environment having upgraded to Professional and downloaded\enabled all the proper packages (.NET 5 & Windows 10 SDK). I tried to install the Windows 7 SDK, but couldn't include the Visual C++ pack because I do not have RTM .NET Framework 4 installed. When I attempted to run the setup for any of the .NET 4 versions, I get this message: "Microsoft .NET Framework 4 is already a part of this operating system. You do not need to install the .NET Framework 4 redistributable. <A HREF="http://go.microsoft.com/fwlink/?LinkId=164207">More information</A>."

I tried to run the Windows 7 SDK without the .NET 4 components, and ran into an issue with the ConfigDetails.htm. When I attempted to go to the link provided (http://go.microsoft.com/fwlink/?LinkId=130245), nothing. As with the included link above and another at 187668.

The Point: what am I doing wrong, should I go about this in a different way, or what? I tried assigning the dword ptr to the register with the corrected value [example: 0) בA43DM) => (0בA43DM) ], but received an error that the character couldn't be handled. I've tried about every way to pass a value in Hebrew, but building the MUI is what I am trying now. Any help would be greatly appreciated. Thanks!

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,430 questions
0 comments No comments
{count} votes

Accepted answer
  1. Drake Wu - MSFT 991 Reputation points
    2021-02-09T02:12:21.237+00:00

    Hi @Brian Grasso

    I am working on a desktop console application that requires the use of non-English characters (Hebrew).

    Do you want to print Hebrew characters in the console? Please check this question on stackoverflow, and also this related topic.
    Here is sample works for me:

    #include <windows.h>  
    #include <iostream>  
    #include <fcntl.h> // for _setmode  
    #include <io.h>  
    int main() {  
        _setmode(_fileno(stdout), _O_U16TEXT);  
        std::wstring hebrewString = L"עברית";  
        std::reverse(hebrewString.begin(), hebrewString.end());  
        CONSOLE_FONT_INFOEX info = { 0 };  
        info.cbSize = sizeof(info);  
        info.dwFontSize.Y = 20;  
        wcscpy_s(info.FaceName, L"Courier New");  
        SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), NULL, &info);  
      
        std::wcout<<hebrewString;  
        return 0;  
    }  
    

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful