none
Print CultureInfo on Console, some native names show "???", how to solve it? RRS feed

  • Question

  • Dear All,

    Print CultureInfo on Console, some native names show "???", how to solve it?

    Thanks and Best regards,

    E-John

                // Displays the properties of each culture.
                int i = 0;
                foreach(CultureInfo myCItrad in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
                {
                    if (myCItrad.LCID < 0xFF)
                    {
    
                        Console.WriteLine("{0,-8}{1,-31}{2,-47}{3, -25}", i.ToString(), myCItrad.LCID, myCItrad.Name, myCItrad.NativeName);
                        i++;
                    }
                }






    • Edited by E-John Wednesday, September 25, 2019 9:32 AM
    Tuesday, September 17, 2019 2:33 PM

All replies

  • Hi,

    Basically, it is due to the font that is being used by the Console showing your text. If the font does not support the character, it will display a question mark.

    You can try to change the font setting for your specific Console Window.

    You can also try to add the following line of code before writing to the Console:

    Console.OutputEncoding = System.Text.Encoding.Unicode;

    Kind regards,

    Johnny Hooyberghs

    Tuesday, September 17, 2019 2:50 PM
  • Hi Johnny,

    It did not work by changing the font on Visual Studio option setting.

    It print more "???" when this line is added "Console.OutputEncoding = System.Text.Encoding.Unicode;"

    Thanks and Best regards,

    E-John

    Tuesday, September 17, 2019 3:19 PM
  • Replace

    myCItrad.NativeName

    by

    myCItrad.DisplayName

    Tuesday, September 17, 2019 4:19 PM
  • Hi Castroix31,

    NativeName instead of DisplayName is used because it is friendly to user who is familiar with his native language.

    I tried to output native name to real console(Not console windows of Visual Studio IDE)

    Some native names still shows "???". The reason of missing characters is that the Font applied doesn't put these missing unicode characters in the Font.

    Is there a Font provided by Microsoft supported all Unicode?

    Thanks and Best regards,

    E-John

    


    • Edited by E-John Thursday, September 19, 2019 5:45 AM
    Thursday, September 19, 2019 5:44 AM
  • Hi E-John, 

    Thanks for your feedback.

    I regret that there is no Font supports all Unicode and maybe such features have not yet been developed.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 24, 2019 9:31 AM
    Moderator
  • Hi Xingyu,

    It works when "Console.WriteLine()" is replaced by "Debug.WriteLine()", see Fig.1(using Console.WriteLine) and Fig.2(Debug.WriteLind)

    Just don't know why.

    Thanks and Best regards,

    E-John

    Fig.1                                                                                                                                               Fig.2


    • Edited by E-John Wednesday, September 25, 2019 3:43 AM
    Wednesday, September 25, 2019 3:42 AM
  • Hi E-John, 

    Debug.WriteLine writes to the trace listeners in the Listeners collection, but only when running in debug. When the application is compiled in the release configuration, the Debug elements will not be compiled into the code.

    You can refer to the following reference about the differences between Console.WriteLine() and Debug.WriteLine().

    What's the difference between Console.WriteLine() vs Debug.WriteLine()?

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 25, 2019 9:23 AM
    Moderator