mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-29 13:17:58 +03:00
31 lines
758 B
C#
31 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));
|
||
|
}
|
||
|
}
|