本文介绍了多行编码和解码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我之前也遇到过类似的问题,所以很抱歉如果我应该只在这里写而不是创建新主题.您在有关从文件进行编码和解码以及将其归档的问题中向我提出了建议:
Hi,
I haved similar problem before so sorry if I should just write it there instead of creating new topic.
You adviced me in my question about encoding and decoding from file and to file this:
public static string encode(string text)
{
byte[] mybyte = System.Text.Encoding.UTF8.GetBytes(text);
string returntext = System.Convert.ToBase64String(mybyte);
return returntext;
}
public static string decode(string text)
{
byte[] mybyte = System.Convert.FromBase64String(text);
string returntext = System.Text.Encoding.UTF8.GetString(mybyte);
return returntext;
}
(虽然有人不建议使用UTF-8:D推荐给我),但是现在看来,当我想用多于两行的文本文件进行编码/解码时,它似乎不起作用.该代码不好吗?
(while someone unrecommended me using UTF-8 :D)but now it seems it doesn''t work when I want to encode/decode from text file with more than two lines. Is that code bad?
推荐答案
这篇关于多行编码和解码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!