Skip to content

Commit d7af603

Browse files
committed
Replaced ReadPrintableAsciiString with ReadString and the correct encoding.
1 parent 3a7404f commit d7af603

7 files changed

Lines changed: 8 additions & 30 deletions

File tree

ReClass.NET/Extensions/EncodingExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static class EncodingExtension
1010
/// <returns>The byte count per character.</returns>
1111
public static int GuessByteCountPerChar(this Encoding encoding)
1212
{
13-
if (encoding.IsSameCodePage(Encoding.UTF8) || encoding.IsSameCodePage(Encoding.ASCII)) return 1;
13+
if (encoding.IsSameCodePage(Encoding.UTF8) || encoding.CodePage == 1252 /* Windows-1252 */ || encoding.IsSameCodePage(Encoding.ASCII)) return 1;
1414
if (encoding.IsSameCodePage(Encoding.Unicode) || encoding.IsSameCodePage(Encoding.BigEndianUnicode)) return 2;
1515
if (encoding.IsSameCodePage(Encoding.UTF32)) return 4;
1616

ReClass.NET/Memory/MemoryBuffer.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -339,31 +339,6 @@ public IntPtr ReadIntPtr(int offset)
339339

340340
#endregion
341341

342-
public string ReadPrintableAsciiString(int offset, int length)
343-
{
344-
Contract.Requires(offset >= 0);
345-
Contract.Requires(length >= 0);
346-
Contract.Ensures(Contract.Result<string>() != null);
347-
348-
if (Offset + offset + length > data.Length)
349-
{
350-
length = Math.Max(data.Length - Offset - offset, 0);
351-
}
352-
353-
if (length <= 0)
354-
{
355-
return string.Empty;
356-
}
357-
358-
var sb = new StringBuilder(length);
359-
for (var i = 0; i < length; ++i)
360-
{
361-
var c = (char)data[Offset + offset + i];
362-
sb.Append(c.IsPrintable() ? c : '.');
363-
}
364-
return sb.ToString();
365-
}
366-
367342
public string ReadString(Encoding encoding, int offset, int length)
368343
{
369344
Contract.Requires(encoding != null);

ReClass.NET/Nodes/Hex16Node.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public override string GetToolTipText(HotSpot spot, MemoryBuffer memory)
2323

2424
public override Size Draw(ViewInfo view, int x, int y)
2525
{
26-
return Draw(view, x, y, view.Settings.ShowNodeText ? view.Memory.ReadPrintableAsciiString(Offset, 2) + " " : null, 2);
26+
return Draw(view, x, y, view.Settings.ShowNodeText ? view.Memory.ReadString(view.Settings.RawDataEncoding, Offset, 2) + " " : null, 2);
2727
}
2828

2929
public override void Update(HotSpot spot)

ReClass.NET/Nodes/Hex32Node.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public override string GetToolTipText(HotSpot spot, MemoryBuffer memory)
3333

3434
public override Size Draw(ViewInfo view, int x, int y)
3535
{
36-
return Draw(view, x, y, view.Settings.ShowNodeText ? view.Memory.ReadPrintableAsciiString(Offset, 4) + " " : null, 4);
36+
return Draw(view, x, y, view.Settings.ShowNodeText ? view.Memory.ReadString(view.Settings.RawDataEncoding, Offset, 4) + " " : null, 4);
3737
}
3838

3939
public override void Update(HotSpot spot)

ReClass.NET/Nodes/Hex64Node.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public override string GetToolTipText(HotSpot spot, MemoryBuffer memory)
3333

3434
public override Size Draw(ViewInfo view, int x, int y)
3535
{
36-
return Draw(view, x, y, view.Settings.ShowNodeText ? view.Memory.ReadPrintableAsciiString(Offset, 8) + " " : null, 8);
36+
return Draw(view, x, y, view.Settings.ShowNodeText ? view.Memory.ReadString(view.Settings.RawDataEncoding, Offset, 8) + " " : null, 8);
3737
}
3838

3939
public override void Update(HotSpot spot)

ReClass.NET/Nodes/Hex8Node.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public override string GetToolTipText(HotSpot spot, MemoryBuffer memory)
2323

2424
public override Size Draw(ViewInfo view, int x, int y)
2525
{
26-
return Draw(view, x, y, view.Settings.ShowNodeText ? view.Memory.ReadPrintableAsciiString(Offset, 1) + " " : null, 1);
26+
return Draw(view, x, y, view.Settings.ShowNodeText ? view.Memory.ReadString(view.Settings.RawDataEncoding, Offset, 1) + " " : null, 1);
2727
}
2828

2929
public override void Update(HotSpot spot)

ReClass.NET/Settings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Drawing;
2+
using System.Text;
23
using ReClassNET.Util;
34

45
namespace ReClassNET
@@ -21,6 +22,8 @@ public class Settings
2122

2223
public bool HighlightChangedValues { get; set; } = true;
2324

25+
public Encoding RawDataEncoding { get; set; } = Encoding.GetEncoding(1252); /* Windows-1252 */
26+
2427
// Comment Drawing Settings
2528

2629
public bool ShowCommentFloat { get; set; } = true;

0 commit comments

Comments
 (0)