UTF8/UTF16和Base64在编码方面有什么区别 [英] What's the difference between UTF8/UTF16 and Base64 in terms of encoding

查看:34
本文介绍了UTF8/UTF16和Base64在编码方面有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.c#

我们可以使用以下类进行编码:

We can use below classes to do encoding:

  • System.Text.Encoding.UTF8
  • System.Text.Encoding.UTF16
  • System.Text.Encoding.ASCII

为什么没有System.Text.Encoding.Base64?

我们只能使用Convert.From(To)Base64String方法,base64有什么特别之处?

We can only use Convert.From(To)Base64String method, what's special of base64?

我能说base64和UTF-8是一样的编码方式吗?或者 UTF-8 是 base64 之一?

Can I say base64 is the same encoding method as UTF-8? Or UTF-8 is one of base64?

推荐答案

UTF-8UTF-16 是将 Unicode 字符串编码为字节序列的方法.

UTF-8 and UTF-16 are methods to encode Unicode strings to byte sequences.

请参阅:每个软件开发人员绝对、肯定必须了解 Unicode 和字符集的绝对最低要求(没有借口!)

Base64 是一种将字节序列编码为字符串的方法.

Base64 is a method to encode a byte sequence to a string.

因此,这些是截然不同的概念,不应混淆.

So, these are widely different concepts and should not be confused.

注意事项:

  • 并非每个字节序列都代表以 UTF-8 或 UTF-16 编码的 Unicode 字符串.

  • Not every byte sequence represents an Unicode string encoded in UTF-8 or UTF-16.

并不是每个 Unicode 字符串都代表一个用 Base64 编码的字节序列.

Not every Unicode string represents a byte sequence encoded in Base64.

这篇关于UTF8/UTF16和Base64在编码方面有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆