基本上我需要将文本框中的文本从UTF-8转换为base16(我认为这就是hex所在的)并将其写入文件。
这个但是背单词:
//Setup byte reader.
FileStream fs = new FileStream(EditOpen.FileName, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
long length = fs.Length;
//Read bytes to textBox1.
br.BaseStream.Position = 0x00001844; //Min loading address.
byte[] PT = br.ReadBytes(0x00000428); //Amount of bytes to load (1064 to be exact).
//Print string PT to textBox1 after converting to UTF-8 and replace 0's with DOT's.
textBox1.Text = System.Text.Encoding.UTF8.GetString(PT).Replace("\0", ".");
fs.Close();
答案 0 :(得分:0)
最简单的方法是使用使用正确的StreamWriter
创建的encoding using(StreamWriter sw =
new System.IO.StreamWriter(fs,
System.Text.UTF8Encoding))
{
sw.Write(textBox1.Text);
}