Skip to content

Instantly share code, notes, and snippets.

@erenes
Created February 11, 2022 21:54
Show Gist options
  • Save erenes/a6edd8f85a415d56db2e1791869f46d0 to your computer and use it in GitHub Desktop.
Save erenes/a6edd8f85a415d56db2e1791869f46d0 to your computer and use it in GitHub Desktop.
Converts a string table from an uexp file (UE4.23) to a CSV file
using System.Text;
var filePath = @"ST_xxxx.uexp";
var outputPath = @"ST_xxxx.csv";
// Open file read only
using var fsRead = File.Open(filePath, FileMode.Open, FileAccess.Read);
using var br = new BinaryReader(fsRead);
// gloss over the header
fsRead.Seek(0xc, SeekOrigin.Begin);
// ST name length:
var nameLen = br.ReadInt32();
var name = br.ReadBytes(nameLen);
// number of entries in ST:
var entries = br.ReadInt32();
Dictionary<string, string> contents = new Dictionary<string, string>();
for (int i = 0; i < entries; i++)
{
var len = br.ReadInt32();
var id = br.ReadBytes(len);
len = br.ReadInt32();
var value = br.ReadBytes(len);
contents.Add(Encoding.UTF8.GetString(id, 0, id.Length - 1), Encoding.UTF8.GetString(value, 0, value.Length - 1));
}
br.Close();
// now convert dictionary to CSV output
using var output = new StreamWriter(outputPath);
// header
output.WriteLine("ID;Text");
foreach (var item in contents)
{
output.WriteLine($"{item.Key};{item.Value}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment