TRX/tools/installer/TRX_InstallerLib/Utils/BinaryReaderExtensions.cs
lahm86 e16fcda94b tools/installer: create common installer library
This creates a generic common installer WPF library for both games.
2025-03-30 12:34:54 +01:00

30 lines
758 B
C#

using System.IO;
using System.Text;
namespace TRX_InstallerLib.Utils;
public static class BinaryReaderExtensions
{
public static string ReadNullTerminatedString(this BinaryReader stream)
{
string str = "";
char ch;
while ((int)(ch = stream.ReadChar()) != 0)
{
str += ch;
}
return str;
}
public static string ReadSystemCodepageString(this BinaryReader stream)
{
var length = stream.ReadUInt16();
return Encoding.Default.GetString(stream.ReadBytes(length));
}
public static string ReadUtf16String(this BinaryReader stream)
{
var length = stream.ReadUInt16();
return Encoding.Unicode.GetString(stream.ReadBytes(length * 2));
}
}