سؤال

I have a Base64 encoded value that was generated in Oracle using

select ... 
utl_encode.base64_encode(utl_raw.cast_to_raw(id)) as encodedid from ...

The original Oracle character set was UTF8 or Unicode. Now I'm trying to decode this in C# but the result is coming back illegible.

        encodedTranscript = "4D7A59344E7A49334D513D3D";
        byte[] encodedTid = Convert.FromBase64String(encodedTranscript);
        String transcriptId = Encoding.Unicode.GetString(encodedTid);

In this case, the resulting transcriptId is illegible. I've tried by Encoding.UTF8 and Encoding.Unicode but both results are illegible.

Any suggestions out there?

Thank you in advance.

هل كانت مفيدة؟

المحلول

You have to know how the "id" was stored originally. What type is the id column? How was it originally encoded? Once you know that, you have to go the inverse path. Supose the id was originally a string in c# UTF8 encoded. Then you got the bytes and stored it as a raw in the database. What you have to do is reading the raw bytes from the database and encode it in UTF8 and voilà.

In the other hand, if you have the id as a utf8 string, then got the bytes and then encoded it to base64, you have to decode the base64 instead of encoding it to raw. Then take the raw bytes and encode them as utf8.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top