Hi,
i cant seem to get my head around this 1. its about utf8 to u32 and vice versa.

I have a file which is written using a custom logic by someone else in vc++, and am reading the same in my c sharp application.

Initially while i was debugging the c++ code, i did find ,there was utf8 and unicode convertion happening while writing on to file, then now i could find there is also utf8 to u32 method.
My question is how do i do that in c sharp.

though, the logic i have written now is, a simple ascii encoding and reading a filestream using the GetString().
ascii supports only upto 0x7f, but i could see 0xA0 and0x8c in the files, could any1 please let me know how would i overcome this problem.

byte[] fileStream = File.ReadAllBytes(Path);
             ASCIIEncoding enc = new ASCIIEncoding();
            string first = enc.GetString(fileStream, 0, 70);

thanks in advance.

Recommended Answers

All 2 Replies

You're almost there...

byte[] fileStream = File.ReadAllBytes(Path);
string first = Encoding.UTF8.GetString(fileStream, 0, 70);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.