2

I am having an issue losing the µ character during encryption/decryption. I convert the string to bytes with Encoding.UTF8.GetBytes and write this to a stream with GZipStream.Write(), and from there to Blob. I noticed that µ is converted to 2 bytes versus the normal characters only being a single byte (I know µ is a 2 byte char).

The stream is decrypted with GZipStream and I use CopyTo(FileStream) to get the bytes to a new File. However, in the new .rtf, µ shows as �. Any ideas? I'm thinking there is an issue with the double byte character, but I'm not really sure.

  • 3
    Well, µ is a two byte character. It looks like you're losing your encoding somewhere along the way. – spodger Oct 20 '17 at 14:38
  • 3
    https://en.wikipedia.org/wiki/Rich_Text_Format#Character_encoding RTF files don't use UTF8 encoding - I suspect that't the problem! – Matthew Watson Oct 20 '17 at 14:41
  • 1
    Can you post a code snippet including all the functionality you have described? – spodger Oct 20 '17 at 14:41
  • I can't really share the code, but the RTF issue sounds very promising, and I can't believe I didn't look into that! Now to see how to maintain the encoding in .rtf. Thanks! – Nick Miethe Oct 20 '17 at 15:09

1 Answers1

1

It looks like Matthew Watson was correct in that rtf doesn't support UTF-8. However, I found this potential solution that I think could be modified to suite my needs.

https://spin.atomicobject.com/2010/08/25/rendering-utf8-characters-in-rich-text-format-with-php/