From 7b024e7f2775e8ada52a58a4ee08c19993387e5b Mon Sep 17 00:00:00 2001 From: Nathan Crawford Date: Mon, 28 Mar 2016 23:23:14 -0400 Subject: [PATCH] Read bytes instead of characters when checking PES format markers, and cast bytes to characters before adding to strings --- PesFile/PesFile.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PesFile/PesFile.cs b/PesFile/PesFile.cs index e5ad734..7045bc9 100644 --- a/PesFile/PesFile.cs +++ b/PesFile/PesFile.cs @@ -128,7 +128,8 @@ namespace PesFile string startFileSig = ""; for (int i = 0; i < 4; i++) // 4 bytes { - startFileSig += fileIn.ReadChar(); + // This needs to be read as a byte, since characters can be multiple bytes depending on encoding + startFileSig += (char)fileIn.ReadByte(); } if (startFileSig != "#PES") { @@ -140,7 +141,8 @@ namespace PesFile string versionString = ""; for (int i = 0; i < 4; i++) // 4 bytes { - versionString += fileIn.ReadChar(); + // This needs to be read as a byte, since characters can be multiple bytes depending on encoding + versionString += (char)fileIn.ReadByte(); } if (!UInt16.TryParse(versionString, out pesVersion)) {