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

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

问题描述

在。 c#



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




  • System.Text.Encoding.UTF8

  • System.Text.Encoding.UTF16

  • System.Text.Encoding.ASCII



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



我们只能用 Convert.From(要)Base64String 方法,有什么特殊的base64的?



我能说Base64是相同的编码方法为UTF- 8?或UTF-8是base64之一?

解决方案

<强> UTF-8 和<强> UTF-16 一些方法来编码Unicode字符串到字节序列。



请参阅:绝对最小每个软件开发人员绝对必须了解Unicode和字符集(No Excuses!)



Base64 是一种对字节进行编码的方法序列到一个字符串。



所以,这些是不同的概念,不应该被混淆。



请记住:




  • 不是每个字节序列都代表以UTF-8或UTF-16编码的Unicode字符串。 >


  • 不是每个Unicode字符串表示Base64中编码的字节序列。



In. c#

We can use below classes to do encoding:

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

Why there is no System.Text.Encoding.Base64?

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

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

解决方案

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

See: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

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

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

Things to keep in mind:

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

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

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

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