What have you learnt about file handling or encoding in this lecture?
I was pretty chuffed with myself for being able to figure this out, but it wasn’t as elegant as Sam’s.
public void Save(string saveFile)
{
string path = GetPathFromSaveFile(saveFile);
byte[] byteArray = new byte[]
{
0xc2,
0xa1,
0x48,
0x6f,
0x6c,
0x61,
0x20,
0x4d,
0x75,
0x6e,
0x64,
0x6f,
0x21
};
print("Saving to " + path);
FileStream stream = File.Open(path, FileMode.Create);
foreach (byte unicode in byteArray)
{
stream.WriteByte(unicode);
}
stream.Close();
}
1 Like