开发者

C# are they the same: Encoding.UTF8.GetBytes & Convert.FromBase64String?

开发者 https://www.devze.com 2023-01-02 23:49 出处:网络
confused by the encoding stuff.are Encoding.UTF8.GetBytes and Convert.FromBase64St开发者_如何学运维ring are the same?er... no.Base64 is a particular way of encoding binary data in an ASCII (7-bit) str

confused by the encoding stuff. are Encoding.UTF8.GetBytes and Convert.FromBase64St开发者_如何学运维ring are the same?


er... no. Base64 is a particular way of encoding binary data in an ASCII (7-bit) stream, usually for transmitting through some other media (email, etc...).

UTF8 is the way of encoding Unicode text as a series of bytes without having to use multiple characters for 7-bit ASCII characters.

In other words: One is for binary data, the other is for text.

Side note: Strings in .NET are already in UTF16, and there are other methods for writing to files and streams as UTF8.

0

精彩评论

暂无评论...
验证码 换一张
取 消