简体   繁体   中英

Losing special unicode characters in encryption (C#)

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM