且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

解码=?UTF-8?B'在C#...?=字符串

更新时间:2023-11-27 12:05:04

让我们来看看的意思MIME编码:????

Let's have a look at the meaning of the MIME encoding:

=?utf-8?B?...something...?=
    ^   ^
    |   +--- The bytes are Base64 encoded
    |
    +---- The string is UTF-8 encoded



所以,解码此,取 ...什么... 你的字符串( 2LPZhNin2YU = 你的情况),然后

So, to decode this, take the ...something... out of your string (2LPZhNin2YU= in your case) and then


  1. 扭转Base64编码

  1. reverse the Base64 encoding

var bytes = Convert.FromBase64String("2LPZhNin2YU=");


  • 解释字节为UTF8字符串

  • interpret the bytes as a UTF8 string

    var text = Encoding.UTF8.GetString(bytes);
    


  • 文本。code>现在应包含所期望的结果。

    text should now contain the desired result.

    这格式的描述可以在***中找到:

    A description of this format can be found in Wikipedia:

    • http://en.wikipedia.org/wiki/MIME#Encoded-Word