Skip to content

Commit

Permalink
changed writeMemory stringEncoding from string to System.Text.Encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
erfg12 committed Dec 28, 2019
1 parent 0acec74 commit 0fe29dd
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions Memory/memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -926,8 +926,8 @@ public string readPString(UIntPtr address, string code, string file = "")
///<param name="type">byte, 2bytes, bytes, float, int, string, double or long.</param>
///<param name="write">value to write to address.</param>
///<param name="file">path and name of .ini file (OPTIONAL)</param>
///<param name="stringEncoding">utf8 (DEFAULT), ascii, unicode, utf32, utf7</param>
public bool writeMemory(string code, string type, string write, string file = "", string stringEncoding = "")
///<param name="stringEncoding">System.Text.Encoding.UTF8 (DEFAULT). Other options: ascii, unicode, utf32, utf7</param>
public bool writeMemory(string code, string type, string write, string file = "", System.Text.Encoding stringEncoding = null)
{
byte[] memory = new byte[4];
int size = 4;
Expand Down Expand Up @@ -997,16 +997,10 @@ public bool writeMemory(string code, string type, string write, string file = ""
else if (type.ToLower() == "string")
{
memory = new byte[write.Length];
if (stringEncoding.ToLower() == "ascii")
memory = System.Text.Encoding.ASCII.GetBytes(write);
else if (stringEncoding.ToLower() == "unicode")
memory = System.Text.Encoding.Unicode.GetBytes(write);
else if (stringEncoding.ToLower() == "utf32")
memory = System.Text.Encoding.UTF32.GetBytes(write);
else if (stringEncoding.ToLower() == "utf7")
memory = System.Text.Encoding.UTF7.GetBytes(write);
else
if (stringEncoding == null)
memory = System.Text.Encoding.UTF8.GetBytes(write);
else
memory = stringEncoding.GetBytes(write);
size = write.Length;
}
//Debug.Write("DEBUG: Writing bytes [TYPE:" + type + " ADDR:" + theCode + "] " + String.Join(",", memory) + Environment.NewLine);
Expand Down

0 comments on commit 0fe29dd

Please sign in to comment.