0

I can see the text in Chinese to display correctly in VSCode, Notepad++, and Notepad. But, when I run the code the Chinese text shows garbled. Here is the code:

// Text used in this sample is taken from the English version of [Disney's Mulan (2020)](https://movies.disney.com/mulan-2020)
// The Chinese text is a translation obtained using Google's translator
// The Spanish text is a translation started with Google's translator and manually adjusted
//
namespace words_and_characters
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(chinese);
            Console.WriteLine(english);
            Console.WriteLine(español);
        }

        static string chinese = @"我對這個無法估量的邀請深感榮幸,但我無法接受,我很抱歉。
我在黑暗的掩護下離開了家,背叛了家人的信任。
我做出了我知道會冒著丟臉的風險的選擇。
從那時起……我發誓:忠誠、勇敢、真實。
為了履行這個誓言,我必須回家,為我的家人做出補償。";

        static string english = @"I'm deeply honored by this immesurable invitation but with humble apologies I cannot accept it.
I left home under cover of darkness and betrayed my family's trust.
I made choices I knew would risk their dishonor.
Since then... I have pledged an oath: to be loyal, brave, and true.
In order to fulfill this oath, I must return home and make amends to my family.";

        static string español = @"Me siento profundamente honrada por esta inconmensurable invitación pero con humildad me disculpo por no poder aceptarla.
Salí de casa al amparo de la oscuridad y traicioné la confianza de mi familia; tomé decisiones que sabía que arriesgarían su deshonra.
Desde entonces... he hecho un juramento: ser leal, valiente y sincera.
Para cumplir este juramento, debo regresar a casa y hacer las paces con mi familia.";
    }
}

Here are the images of what VSCode, Notepad++, and Notepad look like when the source code is opened:

Executing the code generates the following output:

C:\learning\cs\words_and_characters>dotnet run
???????????????,??????,?????
????????????,?????????
???????????????????
????..???:?????????
????????,?????,??????????
I'm deeply honored by this immesurable invitation but with humble apologies I cannot accept it.
I left home under cover of darkness and betrayed my family's trust.
I made choices I knew would risk their dishonor.
Since then... I have pledged an oath: to be loyal, brave, and true.
In order to fulfill this oath, I must return home and make amends to my family.
Me siento profundamente honrada por esta inconmensurable invitación pero con humildad me disculpo por no poder aceptarla.
Salí de casa al amparo de la oscuridad y traicioné la confianza de mi familia; tomé decisiones que sabía que arriesgarían su deshonra.
Desde entonces... he hecho un juramento: ser leal, valiente y sincera.
Para cumplir este juramento, debo regresar a casa y hacer las paces con mi familia.

C:\learning\cs\words_and_characters>

The question is: How can I read the Chinese text and have it in Chinese in CS code.

Note:
I have written a similar example in Python, and Python gets the Chinese chars correctly

0 Answers0