Error "Unable to translate Unicode character" when saving to txt file

Additional Information: It is not possible to translate the Unicode character \ uDFFF to index 195 on the specified code page.

I created an algorithm that results in binary values โ€‹โ€‹(different lengths). I converted it to uintand then to characters and saved in stringbuilder, as you can see below:

uint n = Convert.ToUInt16(tmp_chars, 2);
_koded_text.Append(Convert.ToChar(n));

My problem is that when I try to save these values โ€‹โ€‹in .txt, I get the previously mentioned error.

StreamWriter file = new StreamWriter(filename);
            file.WriteLine(_koded_text);
            file.Close();

What I am saving is: "ๅฟฟ ์ทพ แทฟ] ๋ณฏ ่คŸ ุจุฎูŠ ็—ข ุณู‰ ไผž ูู‘๏žž ใฟฏ ู‘ ็ฟผ ใป ูƒ ูƒ ูƒ ็ญน ๏ทฟ ํŽฟ ๎ž ๎ž ๎ž ๎ž ๎ž ๎ž which are some strange signs.

- txt. - , UTF8 , , . ?

+3
2

. Unicode utf16 .NET. , 65536 . Unicode . , Unicode \uffff ( BMP, Basic Multilingual Plane) . 0xd800 0xdbff, - 0xdc00 0xdfff. 2 ^ (10 + 10) = 1 .

, , (0xdfff), . . , , - , , .

. Base64 - . 6 , 3 - 4 . - ASCII, , , . IBM, EBCDIC, . .

+3

SO : " - base64?" ASCII/ANSI .

0

All Articles