-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaveFileHelper.cs
More file actions
40 lines (31 loc) · 1007 Bytes
/
Copy pathSaveFileHelper.cs
File metadata and controls
40 lines (31 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace IDAS_Save_System
{
public static class SaveFileHelper
{
public static string TryExtractPlayerName(string filePath)
{
try
{
byte[] data = File.ReadAllBytes(filePath);
int offset = 0xF0;
int byteLength = 12;
if (data.Length < offset + byteLength)
return null;
// Decode using Shift-JIS
string rawStr = Encoding.GetEncoding("shift_jis").GetString(data, offset, byteLength);
// Normalize (Shift-JIS full-width to ASCII)
string converted = rawStr.Normalize(NormalizationForm.FormKC);
return converted;
}
catch (Exception ex)
{
MessageBox.Show($"Error extracting name: {ex.Message}");
return null;
}
}
}
}