Question

I try to decrypt a given file, but the content stored is done in C++ using the _bstr_t class. I've been searching for 2 hours already, testing everything and I still didn't get the correct result: reading Korean _bstr_t'd characters as String.

This is the value read in bytes:

B5 B8 BF F2 C3 BC

Which should be, as far as I know, something like 'Arial'. I've tried using the Encoding.Unicode.GetString() , Encoding.UTF8.GetString(), Encoding.UTF7.GetString() , Encoding.UTF32.GetString() methods, none of them returning correct Korean sentences.

Does anyone have an idea how to convert a _bstr_t'd string, converted to bytes, is readable in C#?

Was it helpful?

Solution

Does decoding the bytes with the Windows codepage for Korean produce the output you want?

var bytes = new byte[] { 0xB5, 0xB8, 0xBF, 0xF2, 0xC3, 0xBC };
var output = Encoding.GetEncoding(949).GetString(bytes);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top