从base64和UTF8编码的字符串解码为字节数组 [英] decode from base64 and UTF8 encoded string to byte array

查看:206
本文介绍了从base64和UTF8编码的字符串解码为字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想将base64字符串转换为具有UTF-8编码的字节数组,我正在C#中尝试以下代码:

Hi,

I want to convert a base64 string into a byte array with UTF-8 encoding, I am trying the following code in C#:

byte[] byteArray= System.Text.Encoding.UTF8.GetBytes(resultString);


之后,我想从Base64解码此byteArray并将其存储在byteArray2中.
像在Java中一样,我们使用以下代码:


After this, I want to decode this byteArray from Base64 and store in byteArray2.
Like in java we use following:

byte[] byteArray2=  Base64.decode(byteArray);


请帮帮我.

预先感谢.


Please help me.

Thanks in advance.

推荐答案

Base64已经与ASCII兼容,不需要UTF8编码.

无论如何,请遵循以下链接: http://arcanecode.com/2007/03/21/encoding-strings-to-base64-in-c/ [ C#中的Base64编码器/解码器 [
Base64 is already ASCII compatible and does not need UTF8 encoding.

In any case follow these links : http://arcanecode.com/2007/03/21/encoding-strings-to-base64-in-c/[^]

Base64 Encoder/Decoder in C#[^]


这篇关于从base64和UTF8编码的字符串解码为字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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