diff --git a/src/BizHawk.Common/Extensions/IOExtensions.cs b/src/BizHawk.Common/Extensions/IOExtensions.cs
index e8be70fd1d..507ec47923 100644
--- a/src/BizHawk.Common/Extensions/IOExtensions.cs
+++ b/src/BizHawk.Common/Extensions/IOExtensions.cs
@@ -25,15 +25,24 @@ namespace BizHawk.Common.IOExtensions
return outStream.ToArray();
}
- // Read bytes from a BinaryReader and translate them into the UTF-8 string they represent.
- // WHAT? WHY IS THIS NAMED ASCII BUT USING UTF8
- public static string ReadStringFixedAscii(this BinaryReader r, int bytes)
+ ///
+ /// Read a string from a binary reader using utf8 encoding and known byte length
+ ///
+ ///
+ /// exact number of bytes to read
+ ///
+ public static string ReadStringFixedUtf8(this BinaryReader r, int bytes)
{
var read = new byte[bytes];
r.Read(read, 0, bytes);
return Encoding.UTF8.GetString(read);
}
+ ///
+ /// Read a null terminated string from a binary reader using utf8 encoding
+ ///
+ ///
+ ///
public static string ReadStringUtf8NullTerminated(this BinaryReader br)
{
using var ms = new MemoryStream();
diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NSFFormat.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NSFFormat.cs
index f5f70b8dd4..b975a2b3f8 100644
--- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NSFFormat.cs
+++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NSFFormat.cs
@@ -62,9 +62,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
LoadAddress = br.ReadUInt16();
InitAddress = br.ReadUInt16();
PlayAddress = br.ReadUInt16();
- SongName = br.ReadStringFixedAscii(32);
- ArtistName = br.ReadStringFixedAscii(32);
- CopyrightHolder = br.ReadStringFixedAscii(32);
+ SongName = br.ReadStringFixedUtf8(32);
+ ArtistName = br.ReadStringFixedUtf8(32);
+ CopyrightHolder = br.ReadStringFixedUtf8(32);
SpeedNTSC = br.ReadUInt16();
br.Read(BankswitchInitValues, 0, 8);
SpeedPAL = br.ReadUInt16();
diff --git a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/PSF.cs b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/PSF.cs
index 8670f92c13..3d91a9d1a5 100644
--- a/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/PSF.cs
+++ b/src/BizHawk.Emulation.Cores/Consoles/Sony/PSX/PSF.cs
@@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
{
//not endian safe
var br = new BinaryReader(fs);
- var sig = br.ReadStringFixedAscii(4);
+ var sig = br.ReadStringFixedUtf8(4);
if (sig != "PSF\x1")
return false;
@@ -37,9 +37,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
}
else
{
- if (br.ReadStringFixedAscii(5) == "[TAG]")
+ if (br.ReadStringFixedUtf8(5) == "[TAG]")
{
- var tagstring = br.ReadStringFixedAscii((int)(fs.Length - fs.Position)).Replace("\r\n", "\n");
+ var tagstring = br.ReadStringFixedUtf8((int)(fs.Length - fs.Position)).Replace("\r\n", "\n");
foreach (var tag in tagstring.Split('\n', '\x0'))
{
if (tag.Trim() == "")
diff --git a/src/BizHawk.Emulation.DiscSystem/DiscFormats/SBI_format.cs b/src/BizHawk.Emulation.DiscSystem/DiscFormats/SBI_format.cs
index 45ed1831af..3fb51a07f7 100644
--- a/src/BizHawk.Emulation.DiscSystem/DiscFormats/SBI_format.cs
+++ b/src/BizHawk.Emulation.DiscSystem/DiscFormats/SBI_format.cs
@@ -37,7 +37,7 @@ namespace BizHawk.Emulation.DiscSystem.SBI
using (var fs = File.OpenRead(path))
{
BinaryReader br = new BinaryReader(fs);
- string sig = br.ReadStringFixedAscii(4);
+ string sig = br.ReadStringFixedUtf8(4);
if (sig != "SBI\0")
return false;
}
diff --git a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/LoadSBIJob.cs b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/LoadSBIJob.cs
index 1a62038b6b..dae9c11846 100644
--- a/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/LoadSBIJob.cs
+++ b/src/BizHawk.Emulation.DiscSystem/Internal/Jobs/LoadSBIJob.cs
@@ -25,7 +25,7 @@ namespace BizHawk.Emulation.DiscSystem.SBI
{
using var fs = File.OpenRead(IN_Path);
BinaryReader br = new BinaryReader(fs);
- string sig = br.ReadStringFixedAscii(4);
+ string sig = br.ReadStringFixedUtf8(4);
if (sig != "SBI\0")
throw new SBIParseException("Missing magic number");