diff --git a/DiscImageChef.DiscImages/DART.cs b/DiscImageChef.DiscImages/DART.cs index 78b37eb1..3fa52cda 100644 --- a/DiscImageChef.DiscImages/DART.cs +++ b/DiscImageChef.DiscImages/DART.cs @@ -34,6 +34,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; +using System.Text; using System.Text.RegularExpressions; using Claunia.RsrcFork; using DiscImageChef.CommonTypes; @@ -350,8 +351,7 @@ namespace DiscImageChef.DiscImages Resource dartRsrc = rsrcFork.GetResource(0x44415254); if(dartRsrc != null) { - // TODO: Use MacRoman - string dArt = StringHandlers.PascalToString(dartRsrc.GetResource(dartRsrc.GetIds()[0])); + string dArt = StringHandlers.PascalToString(dartRsrc.GetResource(dartRsrc.GetIds()[0]), Encoding.GetEncoding("macintosh")); string dArtRegEx = "(?\\S+), tag checksum=\\$(?[0123456789ABCDEF]{8}), data checksum=\\$(?[0123456789ABCDEF]{8})$"; Regex dArtEx = new Regex(dArtRegEx); Match dArtMatch = dArtEx.Match(dArt); diff --git a/DiscImageChef.DiscImages/DiscJuggler.cs b/DiscImageChef.DiscImages/DiscJuggler.cs index 7b075ada..7f2527f0 100644 --- a/DiscImageChef.DiscImages/DiscJuggler.cs +++ b/DiscImageChef.DiscImages/DiscJuggler.cs @@ -1,4 +1,4 @@ -// /*************************************************************************** +// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // diff --git a/DiscImageChef.DiscImages/DiskCopy42.cs b/DiscImageChef.DiscImages/DiskCopy42.cs index 42920fac..e9f68f30 100644 --- a/DiscImageChef.DiscImages/DiskCopy42.cs +++ b/DiscImageChef.DiscImages/DiskCopy42.cs @@ -33,6 +33,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; using System.Text.RegularExpressions; using Claunia.RsrcFork; using DiscImageChef.CommonTypes; @@ -178,7 +179,7 @@ namespace DiscImageChef.ImagePlugins BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - tmp_header.diskName = StringHandlers.PascalToString(pString); + tmp_header.diskName = StringHandlers.PascalToString(pString, Encoding.GetEncoding("macintosh")); tmp_header.dataSize = BigEndianBitConverter.ToUInt32(buffer, 0x40); tmp_header.tagSize = BigEndianBitConverter.ToUInt32(buffer, 0x44); tmp_header.dataChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x48); @@ -248,7 +249,7 @@ namespace DiscImageChef.ImagePlugins BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; Array.Copy(buffer, 0, pString, 0, 64); - header.diskName = StringHandlers.PascalToString(pString); + header.diskName = StringHandlers.PascalToString(pString, Encoding.GetEncoding("macintosh")); header.dataSize = BigEndianBitConverter.ToUInt32(buffer, 0x40); header.tagSize = BigEndianBitConverter.ToUInt32(buffer, 0x44); header.dataChecksum = BigEndianBitConverter.ToUInt32(buffer, 0x48); @@ -492,7 +493,7 @@ namespace DiscImageChef.ImagePlugins if(dCpyRsrc != null) { // TODO: Use MacRoman - string dCpy = StringHandlers.PascalToString(dCpyRsrc.GetResource(dCpyRsrc.GetIds()[0])); + string dCpy = StringHandlers.PascalToString(dCpyRsrc.GetResource(dCpyRsrc.GetIds()[0]), Encoding.GetEncoding("macintosh")); string dCpyRegEx = "(?\\S+)\\s(?\\S+)\\rData checksum=\\$(?\\S+)$"; Regex dCpyEx = new Regex(dCpyRegEx); Match dCpyMatch = dCpyEx.Match(dCpy); diff --git a/DiscImageChef.DiscImages/NDIF.cs b/DiscImageChef.DiscImages/NDIF.cs index 93cfa4ba..8b14188d 100644 --- a/DiscImageChef.DiscImages/NDIF.cs +++ b/DiscImageChef.DiscImages/NDIF.cs @@ -34,6 +34,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; +using System.Text; using Claunia.RsrcFork; using DiscImageChef.CommonTypes; using DiscImageChef.Console; @@ -292,7 +293,7 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("NDIF plugin", "footer.type = {0}", header.version); DicConsole.DebugWriteLine("NDIF plugin", "footer.driver = {0}", header.driver); - DicConsole.DebugWriteLine("NDIF plugin", "footer.name = {0}", StringHandlers.PascalToString(header.name)); + DicConsole.DebugWriteLine("NDIF plugin", "footer.name = {0}", StringHandlers.PascalToString(header.name, Encoding.GetEncoding("macintosh"))); DicConsole.DebugWriteLine("NDIF plugin", "footer.sectors = {0}", header.sectors); DicConsole.DebugWriteLine("NDIF plugin", "footer.maxSectorsPerChunk = {0}", header.maxSectorsPerChunk); DicConsole.DebugWriteLine("NDIF plugin", "footer.dataOffset = {0}", header.dataOffset); @@ -443,7 +444,7 @@ namespace DiscImageChef.DiscImages ImageInfo.imageCreationTime = imageFilter.GetCreationTime(); ImageInfo.imageLastModificationTime = imageFilter.GetLastWriteTime(); - ImageInfo.imageName = StringHandlers.PascalToString(header.name); + ImageInfo.imageName = StringHandlers.PascalToString(header.name, Encoding.GetEncoding("macintosh")); ImageInfo.sectorSize = sectorSize; ImageInfo.xmlMediaType = XmlMediaType.BlockMedia; ImageInfo.imageSize = ImageInfo.sectors * sectorSize; diff --git a/DiscImageChef.Filesystems/APFS.cs b/DiscImageChef.Filesystems/APFS.cs index a7038dc2..5b1f3df5 100644 --- a/DiscImageChef.Filesystems/APFS.cs +++ b/DiscImageChef.Filesystems/APFS.cs @@ -46,12 +46,15 @@ namespace DiscImageChef.Filesystems { Name = "Apple File System"; PluginUUID = new Guid("A4060F9D-2909-42E2-9D95-DB31FA7EA797"); + CurrentEncoding = Encoding.UTF8; } - public APFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public APFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Apple File System"; PluginUUID = new Guid("A4060F9D-2909-42E2-9D95-DB31FA7EA797"); + if(encoding == null) + CurrentEncoding = Encoding.UTF8; } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/DiscImageChef.Filesystems/Acorn.cs b/DiscImageChef.Filesystems/Acorn.cs index 85fcf2ea..365109c9 100644 --- a/DiscImageChef.Filesystems/Acorn.cs +++ b/DiscImageChef.Filesystems/Acorn.cs @@ -46,12 +46,15 @@ namespace DiscImageChef.Filesystems { Name = "Acorn Advanced Disc Filing System"; PluginUUID = new Guid("BAFC1E50-9C64-4CD3-8400-80628CC27AFA"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } - public AcornADFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public AcornADFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Acorn Advanced Disc Filing System"; PluginUUID = new Guid("BAFC1E50-9C64-4CD3-8400-80628CC27AFA"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } [StructLayout(LayoutKind.Sequential)] @@ -165,7 +168,7 @@ namespace DiscImageChef.Filesystems DicConsole.DebugWriteLine("ADFS Plugin", "drSb.root = {0}", drSb.root); DicConsole.DebugWriteLine("ADFS Plugin", "drSb.disc_size = {0}", drSb.disc_size); DicConsole.DebugWriteLine("ADFS Plugin", "drSb.disc_id = {0}", drSb.disc_id); - DicConsole.DebugWriteLine("ADFS Plugin", "drSb.disc_name = {0}", StringHandlers.CToString(drSb.disc_name)); + DicConsole.DebugWriteLine("ADFS Plugin", "drSb.disc_name = {0}", StringHandlers.CToString(drSb.disc_name, CurrentEncoding)); DicConsole.DebugWriteLine("ADFS Plugin", "drSb.disc_type = {0}", drSb.disc_type); DicConsole.DebugWriteLine("ADFS Plugin", "drSb.disc_size_high = {0}", drSb.disc_size_high); DicConsole.DebugWriteLine("ADFS Plugin", "drSb.flags = {0}", drSb.flags); @@ -196,7 +199,7 @@ namespace DiscImageChef.Filesystems if(bytes > (imagePlugin.GetSectors() * imagePlugin.GetSectorSize())) return; - string discname = StringHandlers.CToString(drSb.disc_name); + string discname = StringHandlers.CToString(drSb.disc_name, CurrentEncoding); sbInformation.AppendLine("Acorn Advanced Disc Filing System"); sbInformation.AppendLine(); diff --git a/DiscImageChef.Filesystems/AmigaDOS.cs b/DiscImageChef.Filesystems/AmigaDOS.cs index db0828a5..fa05ed30 100644 --- a/DiscImageChef.Filesystems/AmigaDOS.cs +++ b/DiscImageChef.Filesystems/AmigaDOS.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "Amiga DOS filesystem"; PluginUUID = new Guid("3c882400-208c-427d-a086-9119852a1bc7"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } - public AmigaDOSPlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public AmigaDOSPlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Amiga DOS filesystem"; PluginUUID = new Guid("3c882400-208c-427d-a086-9119852a1bc7"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } /// @@ -305,7 +308,7 @@ namespace DiscImageChef.Filesystems rootBlk.rTicks = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 116)); Array.Copy(RootBlockSector, 0x18 + rootBlk.hashTableSize * 4 + 120, diskName, 0, 32); - rootBlk.diskName = StringHandlers.PascalToString(diskName); + rootBlk.diskName = StringHandlers.PascalToString(diskName, CurrentEncoding); rootBlk.reserved1 = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 152)); rootBlk.reserved2 = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 156)); diff --git a/DiscImageChef.Filesystems/AppleDOS/AppleDOS.cs b/DiscImageChef.Filesystems/AppleDOS/AppleDOS.cs index 6cdfd646..86ab90e9 100644 --- a/DiscImageChef.Filesystems/AppleDOS/AppleDOS.cs +++ b/DiscImageChef.Filesystems/AppleDOS/AppleDOS.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; +using System.Text; using DiscImageChef.ImagePlugins; namespace DiscImageChef.Filesystems.AppleDOS @@ -75,14 +76,17 @@ namespace DiscImageChef.Filesystems.AppleDOS { Name = "Apple DOS File System"; PluginUUID = new Guid("8658A1E9-B2E7-4BCC-9638-157A31B0A700\n"); + CurrentEncoding = new Claunia.Encoding.LisaRoman(); } - public AppleDOS(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public AppleDOS(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { device = imagePlugin; start = partitionStart; Name = "Apple DOS File System"; PluginUUID = new Guid("8658A1E9-B2E7-4BCC-9638-157A31B0A700\n"); + if(encoding == null) // TODO: Until Apple ][ encoding is implemented + CurrentEncoding = new Claunia.Encoding.LisaRoman(); } } } diff --git a/DiscImageChef.Filesystems/AppleDOS/Dir.cs b/DiscImageChef.Filesystems/AppleDOS/Dir.cs index 7873aca2..46323b57 100644 --- a/DiscImageChef.Filesystems/AppleDOS/Dir.cs +++ b/DiscImageChef.Filesystems/AppleDOS/Dir.cs @@ -122,7 +122,7 @@ namespace DiscImageChef.Filesystems.AppleDOS for(int i = 0; i < 30; i++) filename_b[i] = (byte)(entry.filename[i] & 0x7F); - string filename = StringHandlers.SpacePaddedToString(filename_b); + string filename = StringHandlers.SpacePaddedToString(filename_b, CurrentEncoding); if(!catalogCache.ContainsKey(filename)) catalogCache.Add(filename, ts); diff --git a/DiscImageChef.Filesystems/AppleHFS.cs b/DiscImageChef.Filesystems/AppleHFS.cs index 842d5675..b9e27573 100644 --- a/DiscImageChef.Filesystems/AppleHFS.cs +++ b/DiscImageChef.Filesystems/AppleHFS.cs @@ -58,12 +58,15 @@ namespace DiscImageChef.Filesystems { Name = "Apple Hierarchical File System"; PluginUUID = new Guid("36405F8D-0D26-6ECC-0BBB-1D5225FF404F"); + CurrentEncoding = Encoding.GetEncoding("macintosh"); } - public AppleHFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public AppleHFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Apple Hierarchical File System"; PluginUUID = new Guid("36405F8D-0D26-6ECC-0BBB-1D5225FF404F"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("macintosh"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -181,7 +184,7 @@ namespace DiscImageChef.Filesystems MDB.drFreeBks = BigEndianBitConverter.ToUInt16(mdb_sector, 0x022); pString = new byte[28]; Array.Copy(mdb_sector, 0x024, pString, 0, 28); - MDB.drVN = StringHandlers.PascalToString(pString); + MDB.drVN = StringHandlers.PascalToString(pString, CurrentEncoding); MDB.drVolBkUp = BigEndianBitConverter.ToUInt32(mdb_sector, 0x040); MDB.drVSeqNum = BigEndianBitConverter.ToUInt16(mdb_sector, 0x044); @@ -225,25 +228,25 @@ namespace DiscImageChef.Filesystems pString = new byte[16]; Array.Copy(bb_sector, 0x00A, pString, 0, 16); - BB.system_name = StringHandlers.PascalToString(pString); + BB.system_name = StringHandlers.PascalToString(pString, CurrentEncoding); pString = new byte[16]; Array.Copy(bb_sector, 0x01A, pString, 0, 16); - BB.finder_name = StringHandlers.PascalToString(pString); + BB.finder_name = StringHandlers.PascalToString(pString, CurrentEncoding); pString = new byte[16]; Array.Copy(bb_sector, 0x02A, pString, 0, 16); - BB.debug_name = StringHandlers.PascalToString(pString); + BB.debug_name = StringHandlers.PascalToString(pString, CurrentEncoding); pString = new byte[16]; Array.Copy(bb_sector, 0x03A, pString, 0, 16); - BB.disasm_name = StringHandlers.PascalToString(pString); + BB.disasm_name = StringHandlers.PascalToString(pString, CurrentEncoding); pString = new byte[16]; Array.Copy(bb_sector, 0x04A, pString, 0, 16); - BB.stupscr_name = StringHandlers.PascalToString(pString); + BB.stupscr_name = StringHandlers.PascalToString(pString, CurrentEncoding); pString = new byte[16]; Array.Copy(bb_sector, 0x05A, pString, 0, 16); - BB.bootup_name = StringHandlers.PascalToString(pString); + BB.bootup_name = StringHandlers.PascalToString(pString, CurrentEncoding); pString = new byte[16]; Array.Copy(bb_sector, 0x06A, pString, 0, 16); - BB.clipbrd_name = StringHandlers.PascalToString(pString); + BB.clipbrd_name = StringHandlers.PascalToString(pString, CurrentEncoding); BB.max_files = BigEndianBitConverter.ToUInt16(bb_sector, 0x07A); BB.queue_size = BigEndianBitConverter.ToUInt16(bb_sector, 0x07C); diff --git a/DiscImageChef.Filesystems/AppleHFSPlus.cs b/DiscImageChef.Filesystems/AppleHFSPlus.cs index 00322aad..d4c8a246 100644 --- a/DiscImageChef.Filesystems/AppleHFSPlus.cs +++ b/DiscImageChef.Filesystems/AppleHFSPlus.cs @@ -56,12 +56,15 @@ namespace DiscImageChef.Filesystems { Name = "Apple HFS+ filesystem"; PluginUUID = new Guid("36405F8D-0D26-6EBE-436F-62F0586B4F08"); + CurrentEncoding = Encoding.UTF8; } - public AppleHFSPlus(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public AppleHFSPlus(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Apple HFS+ filesystem"; PluginUUID = new Guid("36405F8D-0D26-6EBE-436F-62F0586B4F08"); + if(encoding == null) + CurrentEncoding = Encoding.UTF8; } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filesystems/AppleMFS/AppleMFS.cs b/DiscImageChef.Filesystems/AppleMFS/AppleMFS.cs index b982ba90..994206a9 100644 --- a/DiscImageChef.Filesystems/AppleMFS/AppleMFS.cs +++ b/DiscImageChef.Filesystems/AppleMFS/AppleMFS.cs @@ -33,6 +33,7 @@ using System; using System.Collections.Generic; using DiscImageChef.ImagePlugins; +using System.Text; namespace DiscImageChef.Filesystems.AppleMFS { @@ -64,14 +65,17 @@ namespace DiscImageChef.Filesystems.AppleMFS { Name = "Apple Macintosh File System"; PluginUUID = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A"); + CurrentEncoding = Encoding.GetEncoding("macintosh"); } - public AppleMFS(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public AppleMFS(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Apple Macintosh File System"; PluginUUID = new Guid("36405F8D-0D26-4066-6538-5DBF5D065C3A"); device = imagePlugin; this.partitionStart = partitionStart; + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("macintosh"); } } } diff --git a/DiscImageChef.Filesystems/AppleMFS/Dir.cs b/DiscImageChef.Filesystems/AppleMFS/Dir.cs index 20c135ff..1a282787 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Dir.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Dir.cs @@ -93,14 +93,14 @@ namespace DiscImageChef.Filesystems.AppleMFS entry.flMdDat = BigEndianBitConverter.ToUInt32(directoryBlocks, offset + 46); entry.flNam = new byte[directoryBlocks[offset + 50] + 1]; Array.Copy(directoryBlocks, offset + 50, entry.flNam, 0, entry.flNam.Length); - lowerFilename = GetStringFromPascal(entry.flNam).ToLowerInvariant().Replace('/', ':'); + lowerFilename = StringHandlers.PascalToString(entry.flNam, CurrentEncoding).ToLowerInvariant().Replace('/', ':'); if(entry.flFlags.HasFlag(MFS_FileFlags.Used) && !idToFilename.ContainsKey(entry.flFlNum) && !idToEntry.ContainsKey(entry.flFlNum) && !filenameToId.ContainsKey(lowerFilename) && entry.flFlNum > 0) { idToEntry.Add(entry.flFlNum, entry); - idToFilename.Add(entry.flFlNum, GetStringFromPascal(entry.flNam).Replace('/', ':')); + idToFilename.Add(entry.flFlNum, StringHandlers.PascalToString(entry.flNam, CurrentEncoding).Replace('/', ':')); filenameToId.Add(lowerFilename, entry.flFlNum); DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flFlags = {0}", entry.flFlags); @@ -114,7 +114,7 @@ namespace DiscImageChef.Filesystems.AppleMFS DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flRPyLen = {0}", entry.flRPyLen); DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flCrDat = {0}", DateHandlers.MacToDateTime(entry.flCrDat)); DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flMdDat = {0}", DateHandlers.MacToDateTime(entry.flMdDat)); - DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flNam0 = {0}", GetStringFromPascal(entry.flNam)); + DicConsole.DebugWriteLine("DEBUG (AppleMFS plugin)", "entry.flNam0 = {0}", StringHandlers.PascalToString(entry.flNam, CurrentEncoding)); } offset += (50 + entry.flNam.Length); diff --git a/DiscImageChef.Filesystems/AppleMFS/Encoding.cs b/DiscImageChef.Filesystems/AppleMFS/Encoding.cs deleted file mode 100644 index 7a4462b6..00000000 --- a/DiscImageChef.Filesystems/AppleMFS/Encoding.cs +++ /dev/null @@ -1,164 +0,0 @@ -// /*************************************************************************** -// The Disc Image Chef -// ---------------------------------------------------------------------------- -// -// Filename : Encoding.cs -// Author(s) : Natalia Portillo -// -// Component : Apple Macintosh File System plugin. -// -// --[ Description ] ---------------------------------------------------------- -// -// Apple MacRoman to Unicode converters. -// -// --[ License ] -------------------------------------------------------------- -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2011-2017 Natalia Portillo -// ****************************************************************************/ - -namespace DiscImageChef.Filesystems.AppleMFS -{ - // Information from Inside Macintosh Volume II - partial class AppleMFS : Filesystem - { - /// - /// The MacRoman to Unicode character map. - /// - static readonly char[] MacRomanTable = { - // 0x00 - '\u0000','\u0001','\u0002','\u0003','\u0004','\u0005','\u0006','\u0007', - // 0x08 - '\u0008','\u0009','\u000A','\u000B','\u000C','\u000D','\u000E','\u000F', - // 0x10 - '\u0010','\u0011','\u0012','\u0013','\u0014','\u0015','\u0016','\u0017', - // 0x18 - '\u0018','\u0019','\u001A','\u001B','\u001C','\u001D','\u001E','\u001F', - // 0x20 - '\u0020','\u0021','\u0022','\u0023','\u0024','\u0025','\u0026','\u0027', - // 0x28 - '\u0028','\u0029','\u002A','\u002B','\u002C','\u002D','\u002E','\u002F', - // 0x30 - '\u0030','\u0031','\u0032','\u0033','\u0034','\u0035','\u0036','\u0037', - // 0x38 - '\u0038','\u0039','\u003A','\u003B','\u003C','\u003D','\u003E','\u003F', - // 0x40 - '\u0040','\u0041','\u0042','\u0043','\u0044','\u0045','\u0046','\u0047', - // 0x48 - '\u0048','\u0049','\u004A','\u004B','\u004C','\u004D','\u004E','\u004F', - // 0x50 - '\u0050','\u0051','\u0052','\u0053','\u0054','\u0055','\u0056','\u0057', - // 0x58 - '\u0058','\u0059','\u005A','\u005B','\u005C','\u005D','\u005E','\u005F', - // 0x60 - '\u0060','\u0061','\u0062','\u0063','\u0064','\u0065','\u0066','\u0067', - // 0x68 - '\u0068','\u0069','\u006A','\u006B','\u006C','\u006D','\u006E','\u006F', - // 0x70 - '\u0070','\u0071','\u0072','\u0073','\u0074','\u0075','\u0076','\u0077', - // 0x78 - '\u0078','\u0079','\u007A','\u007B','\u007C','\u007D','\u007E','\u007F', - // 0x80 - '\u00C4','\u00C5','\u00C7','\u00C9','\u00D1','\u00D6','\u00DC','\u00E1', - // 0x88 - '\u00E0','\u00E2','\u00E4','\u00E3','\u00E5','\u00E7','\u00E9','\u00E8', - // 0x90 - '\u00EA','\u00EB','\u00ED','\u00EC','\u00EE','\u00EF','\u00F1','\u00F3', - // 0x98 - '\u00F2','\u00F4','\u00F6','\u00F5','\u00FA','\u00F9','\u00FB','\u00FC', - // 0xA0 - '\u2020','\u00B0','\u00A2','\u00A3','\u00A7','\u2022','\u00B6','\u00DF', - // 0xA8 - '\u00AE','\u00A9','\u2122','\u00B4','\u00A8','\u2260','\u00C6','\u00D8', - // 0xB0 - '\u221E','\u00B1','\u2264','\u2265','\u00A5','\u00B5','\u2202','\u2211', - // 0xB8 - '\u220F','\u03C0','\u222B','\u00AA','\u00BA','\u03A9','\u00E6','\u00F8', - // 0xC0 - '\u00BF','\u00A1','\u00AC','\u221A','\u0192','\u2248','\u2206','\u00AB', - // 0xC8 - '\u00BB','\u2026','\u00A0','\u00C0','\u00C3','\u00D5','\u0152','\u0153', - // 0xD0 - '\u2013','\u2014','\u201C','\u201D','\u2018','\u2019','\u00F7','\u25CA', - // 0xD8 - '\u00FF','\u0178','\u2044','\u00A4','\u2039','\u203A','\uFB01','\uFB02', - // 0xE0 - '\u2021','\u00B7','\u201A','\u201E','\u2030','\u00C2','\u00CA','\u00C1', - // 0xE8 - '\u00CB','\u00C8','\u00CD','\u00CE','\u00CF','\u00CC','\u00D3','\u00D4', - // 0xF0 - '\uF8FF','\u00D2','\u00DA','\u00DB','\u00D9','\u0131','\u02C6','\u02DC', - // 0xF8 - '\u00AF','\u02D8','\u02D9','\u02DA','\u00B8','\u02DD','\u02DB','\u02C7' - }; - - /// - /// Converts a MacRoman character to an Unicode character - /// - /// Unicode character. - /// MacRoman character. - static char GetChar(byte character) - { - return MacRomanTable[character]; - } - - /// - /// Converts a MacRoman string, null-terminated or null-paded, to a C# string - /// - /// The C# string. - /// MacRoman string. - static string GetString(byte[] str) - { - string uni = ""; - - foreach(byte b in str) - { - if(b == 0x00) - break; - - uni += MacRomanTable[b]; - } - - return uni; - } - - /// - /// Converts a MacRoman string, in Pascal length-prefixed format, to a C# string - /// - /// The C# string. - /// The MacRoman string in Pascal format. - static string GetStringFromPascal(byte[] PascalString) - { - if(PascalString == null) - return null; - - string uni = ""; - - byte length = PascalString[0]; - - if(length > PascalString.Length - 1) - length = (byte)(PascalString.Length - 1); - - for(int i = 1; i < length + 1; i++) - { - uni += MacRomanTable[PascalString[i]]; - } - - return uni; - } - } -} - diff --git a/DiscImageChef.Filesystems/AppleMFS/Info.cs b/DiscImageChef.Filesystems/AppleMFS/Info.cs index 72fef741..993eb171 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Info.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Info.cs @@ -90,7 +90,7 @@ namespace DiscImageChef.Filesystems.AppleMFS MDB.drVNSiz = mdb_sector[0x024]; variable_size = new byte[MDB.drVNSiz+1]; Array.Copy(mdb_sector, 0x024, variable_size, 0, MDB.drVNSiz+1); - MDB.drVN = GetStringFromPascal(variable_size); + MDB.drVN = StringHandlers.PascalToString(variable_size, CurrentEncoding); BB.signature = BigEndianBitConverter.ToUInt16(bb_sector, 0x000); @@ -103,19 +103,19 @@ namespace DiscImageChef.Filesystems.AppleMFS BB.sec_sv_pages = BigEndianBitConverter.ToInt16(bb_sector, 0x008); Array.Copy(mdb_sector, 0x00A, pString, 0, 16); - BB.system_name = GetStringFromPascal(pString); + BB.system_name = StringHandlers.PascalToString(pString, CurrentEncoding); Array.Copy(mdb_sector, 0x01A, pString, 0, 16); - BB.finder_name = GetStringFromPascal(pString); + BB.finder_name = StringHandlers.PascalToString(pString, CurrentEncoding); Array.Copy(mdb_sector, 0x02A, pString, 0, 16); - BB.debug_name = GetStringFromPascal(pString); + BB.debug_name = StringHandlers.PascalToString(pString, CurrentEncoding); Array.Copy(mdb_sector, 0x03A, pString, 0, 16); - BB.disasm_name = GetStringFromPascal(pString); + BB.disasm_name = StringHandlers.PascalToString(pString, CurrentEncoding); Array.Copy(mdb_sector, 0x04A, pString, 0, 16); - BB.stupscr_name = GetStringFromPascal(pString); + BB.stupscr_name = StringHandlers.PascalToString(pString, CurrentEncoding); Array.Copy(mdb_sector, 0x05A, pString, 0, 16); - BB.bootup_name = GetStringFromPascal(pString); + BB.bootup_name = StringHandlers.PascalToString(pString, CurrentEncoding); Array.Copy(mdb_sector, 0x06A, pString, 0, 16); - BB.clipbrd_name = GetStringFromPascal(pString); + BB.clipbrd_name = StringHandlers.PascalToString(pString, CurrentEncoding); BB.max_files = BigEndianBitConverter.ToUInt16(bb_sector, 0x07A); BB.queue_size = BigEndianBitConverter.ToUInt16(bb_sector, 0x07C); diff --git a/DiscImageChef.Filesystems/AppleMFS/Super.cs b/DiscImageChef.Filesystems/AppleMFS/Super.cs index 828c6d1a..f071f062 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Super.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Super.cs @@ -69,7 +69,7 @@ namespace DiscImageChef.Filesystems.AppleMFS volMDB.drVNSiz = mdbBlocks[0x024]; variable_size = new byte[volMDB.drVNSiz + 1]; Array.Copy(mdbBlocks, 0x024, variable_size, 0, volMDB.drVNSiz + 1); - volMDB.drVN = GetStringFromPascal(variable_size); + volMDB.drVN = StringHandlers.PascalToString(variable_size, CurrentEncoding); directoryBlocks = device.ReadSectors(volMDB.drDirSt + partitionStart, volMDB.drBlLen); int bytesInBlockMap = ((volMDB.drNmAlBlks * 12) / 8) + ((volMDB.drNmAlBlks * 12) % 8); diff --git a/DiscImageChef.Filesystems/BFS.cs b/DiscImageChef.Filesystems/BFS.cs index 382b3df6..cd2ea280 100644 --- a/DiscImageChef.Filesystems/BFS.cs +++ b/DiscImageChef.Filesystems/BFS.cs @@ -55,12 +55,15 @@ namespace DiscImageChef.Filesystems { Name = "Be Filesystem"; PluginUUID = new Guid("dc8572b3-b6ad-46e4-8de9-cbe123ff6672"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public BeFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public BeFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Be Filesystem"; PluginUUID = new Guid("dc8572b3-b6ad-46e4-8de9-cbe123ff6672"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -144,7 +147,7 @@ namespace DiscImageChef.Filesystems } Array.Copy(sb_sector, 0x000, name_bytes, 0, 0x20); - besb.name = StringHandlers.CToString(name_bytes); + besb.name = StringHandlers.CToString(name_bytes, CurrentEncoding); besb.magic1 = BigEndianBitConverter.ToUInt32(sb_sector, 0x20); besb.fs_byte_order = BigEndianBitConverter.ToUInt32(sb_sector, 0x24); besb.block_size = BigEndianBitConverter.ToUInt32(sb_sector, 0x28); diff --git a/DiscImageChef.Filesystems/BTRFS.cs b/DiscImageChef.Filesystems/BTRFS.cs index 83d1411a..08ba2479 100644 --- a/DiscImageChef.Filesystems/BTRFS.cs +++ b/DiscImageChef.Filesystems/BTRFS.cs @@ -49,12 +49,15 @@ namespace DiscImageChef.Filesystems { Name = "B-tree file system"; PluginUUID = new Guid("C904CF15-5222-446B-B7DB-02EAC5D781B3"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public BTRFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public BTRFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "B-tree file system"; PluginUUID = new Guid("C904CF15-5222-446B-B7DB-02EAC5D781B3"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/DiscImageChef.Filesystems/CBM.cs b/DiscImageChef.Filesystems/CBM.cs index e3c3c927..c1504ec0 100644 --- a/DiscImageChef.Filesystems/CBM.cs +++ b/DiscImageChef.Filesystems/CBM.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "Commodore file system"; PluginUUID = new Guid("D104744E-A376-450C-BAC0-1347C93F983B"); + CurrentEncoding = new Claunia.Encoding.PETSCII(); } - public CBM(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public CBM(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Commodore file system"; PluginUUID = new Guid("D104744E-A376-450C-BAC0-1347C93F983B"); + if(encoding == null) + CurrentEncoding = new Claunia.Encoding.PETSCII(); } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -246,9 +249,9 @@ namespace DiscImageChef.Filesystems sbInformation.AppendFormat("Disk Version: {0}", Encoding.ASCII.GetString(new byte[] { cbmHdr.diskVersion })).AppendLine(); sbInformation.AppendFormat("Disk ID: {0}", cbmHdr.diskId).AppendLine(); // TODO: Use PETSCII - sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmHdr.name)).AppendLine(); + sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmHdr.name, CurrentEncoding)).AppendLine(); - xmlFSType.VolumeName = StringHandlers.CToString(cbmHdr.name); + xmlFSType.VolumeName = StringHandlers.CToString(cbmHdr.name, CurrentEncoding); xmlFSType.VolumeSerial = string.Format("{0}", cbmHdr.diskId); } else @@ -265,9 +268,9 @@ namespace DiscImageChef.Filesystems sbInformation.AppendFormat("DOS Version: {0}", Encoding.ASCII.GetString(new byte[] { cbmBam.dosVersion })).AppendLine(); sbInformation.AppendFormat("Disk ID: {0}", cbmBam.diskId).AppendLine(); // TODO: Use PETSCII - sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmBam.name)).AppendLine(); + sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(cbmBam.name, CurrentEncoding)).AppendLine(); - xmlFSType.VolumeName = StringHandlers.CToString(cbmBam.name); + xmlFSType.VolumeName = StringHandlers.CToString(cbmBam.name, CurrentEncoding); xmlFSType.VolumeSerial = string.Format("{0}", cbmBam.diskId); } diff --git a/DiscImageChef.Filesystems/CPM/CPM.cs b/DiscImageChef.Filesystems/CPM/CPM.cs index 0e59a21d..9a77248b 100644 --- a/DiscImageChef.Filesystems/CPM/CPM.cs +++ b/DiscImageChef.Filesystems/CPM/CPM.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; +using System.Text; using DiscImageChef.ImagePlugins; namespace DiscImageChef.Filesystems.CPM @@ -113,15 +114,18 @@ namespace DiscImageChef.Filesystems.CPM { Name = "CP/M File System"; PluginUUID = new Guid("AA2B8585-41DF-4E3B-8A35-D1A935E2F8A1"); + CurrentEncoding = Encoding.GetEncoding("IBM437"); } - public CPM(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public CPM(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { device = imagePlugin; partStart = partitionStart; partEnd = partitionEnd; Name = "CP/M File System"; PluginUUID = new Guid("AA2B8585-41DF-4E3B-8A35-D1A935E2F8A1"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("IBM437"); } } } diff --git a/DiscImageChef.Filesystems/Cram.cs b/DiscImageChef.Filesystems/Cram.cs index 99c7d55b..83af16f3 100644 --- a/DiscImageChef.Filesystems/Cram.cs +++ b/DiscImageChef.Filesystems/Cram.cs @@ -44,12 +44,15 @@ namespace DiscImageChef.Filesystems { Name = "Cram filesystem"; PluginUUID = new Guid("F8F6E46F-7A2A-48E3-9C0A-46AF4DC29E09"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public Cram(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public Cram(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Cram filesystem"; PluginUUID = new Guid("F8F6E46F-7A2A-48E3-9C0A-46AF4DC29E09"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } enum CramCompression : ushort @@ -125,7 +128,7 @@ namespace DiscImageChef.Filesystems else sbInformation.AppendLine("Big-endian"); sbInformation.AppendFormat("Volume edition {0}", crSb.edition).AppendLine(); - sbInformation.AppendFormat("Volume name: {0}", StringHandlers.CToString(crSb.name)).AppendLine(); + sbInformation.AppendFormat("Volume name: {0}", StringHandlers.CToString(crSb.name, CurrentEncoding)).AppendLine(); sbInformation.AppendFormat("Volume has {0} bytes", crSb.size).AppendLine(); sbInformation.AppendFormat("Volume has {0} blocks", crSb.blocks).AppendLine(); sbInformation.AppendFormat("Volume has {0} files", crSb.files).AppendLine(); @@ -133,7 +136,7 @@ namespace DiscImageChef.Filesystems information = sbInformation.ToString(); xmlFSType = new Schemas.FileSystemType(); - xmlFSType.VolumeName = StringHandlers.CToString(crSb.name); + xmlFSType.VolumeName = StringHandlers.CToString(crSb.name, CurrentEncoding); xmlFSType.Type = "Cram file system"; xmlFSType.Clusters = crSb.blocks; xmlFSType.Files = crSb.files; diff --git a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj index cac9b6b2..e4ce36a7 100644 --- a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj +++ b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj @@ -33,6 +33,9 @@ + + ..\packages\Claunia.Encoding.1.0.1\lib\portable40-net40+sl5+win8+wp8\Claunia.Encoding.dll + @@ -82,7 +85,6 @@ - @@ -173,6 +175,9 @@ + + + @@ -181,7 +186,7 @@ - + diff --git a/DiscImageChef.Filesystems/ECMA67.cs b/DiscImageChef.Filesystems/ECMA67.cs index cf734a35..cbe467fe 100644 --- a/DiscImageChef.Filesystems/ECMA67.cs +++ b/DiscImageChef.Filesystems/ECMA67.cs @@ -45,12 +45,15 @@ namespace DiscImageChef.Filesystems { Name = "ECMA-67"; PluginUUID = new Guid("62A2D44A-CBC1-4377-B4B6-28C5C92034A1"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } - public ECMA67(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public ECMA67(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "ECMA-67"; PluginUUID = new Guid("62A2D44A-CBC1-4377-B4B6-28C5C92034A1"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } readonly byte[] ECMA67_Magic = { 0x56, 0x4F, 0x4C }; diff --git a/DiscImageChef.Filesystems/F2FS.cs b/DiscImageChef.Filesystems/F2FS.cs index cb31084b..d0ee3a17 100644 --- a/DiscImageChef.Filesystems/F2FS.cs +++ b/DiscImageChef.Filesystems/F2FS.cs @@ -112,12 +112,15 @@ namespace DiscImageChef.Filesystems { Name = "F2FS Plugin"; PluginUUID = new Guid("82B0920F-5F0D-4063-9F57-ADE0AE02ECE5"); + CurrentEncoding = Encoding.Unicode; } - public F2FS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public F2FS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "F2FS Plugin"; PluginUUID = new Guid("82B0920F-5F0D-4063-9F57-ADE0AE02ECE5"); + if(encoding == null) + CurrentEncoding = Encoding.Unicode; } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filesystems/FAT.cs b/DiscImageChef.Filesystems/FAT.cs index 7c3f6e67..5267c6b4 100644 --- a/DiscImageChef.Filesystems/FAT.cs +++ b/DiscImageChef.Filesystems/FAT.cs @@ -45,12 +45,15 @@ namespace DiscImageChef.Filesystems { Name = "Microsoft File Allocation Table"; PluginUUID = new Guid("33513B2C-0D26-0D2D-32C3-79D8611158E0"); + CurrentEncoding = Encoding.GetEncoding("IBM437"); } - public FAT(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public FAT(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Microsoft File Allocation Table"; PluginUUID = new Guid("33513B2C-0D26-0D2D-32C3-79D8611158E0"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("IBM437"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -282,7 +285,7 @@ namespace DiscImageChef.Filesystems FAT32PB.serial_no = BitConverter.ToUInt32(bpb_sector, 0x43); dosString = new byte[11]; Array.Copy(bpb_sector, 0x47, dosString, 0, 11); - FAT32PB.volume_label = StringHandlers.CToString(dosString); + FAT32PB.volume_label = StringHandlers.CToString(dosString, CurrentEncoding); dosString = new byte[8]; Array.Copy(bpb_sector, 0x52, dosString, 0, 8); FAT32PB.fs_type = StringHandlers.CToString(dosString); @@ -295,7 +298,7 @@ namespace DiscImageChef.Filesystems EPB.serial_no = BitConverter.ToUInt32(bpb_sector, 0x27); dosString = new byte[11]; Array.Copy(bpb_sector, 0x2B, dosString, 0, 11); - EPB.volume_label = StringHandlers.CToString(dosString); + EPB.volume_label = StringHandlers.CToString(dosString, CurrentEncoding); dosString = new byte[8]; Array.Copy(bpb_sector, 0x36, dosString, 0, 8); EPB.fs_type = StringHandlers.CToString(dosString); diff --git a/DiscImageChef.Filesystems/FATX.cs b/DiscImageChef.Filesystems/FATX.cs index a431ce66..6a2ac5f2 100644 --- a/DiscImageChef.Filesystems/FATX.cs +++ b/DiscImageChef.Filesystems/FATX.cs @@ -54,12 +54,15 @@ namespace DiscImageChef.Filesystems { Name = "FATX Filesystem Plugin"; PluginUUID = new Guid("ED27A721-4A17-4649-89FD-33633B46E228"); + CurrentEncoding = Encoding.UTF8; } - public FATX(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public FATX(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "FATX Filesystem Plugin"; PluginUUID = new Guid("ED27A721-4A17-4649-89FD-33633B46E228"); + if(encoding == null) + CurrentEncoding = Encoding.UTF8; } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filesystems/FFS.cs b/DiscImageChef.Filesystems/FFS.cs index 818b0436..47396989 100644 --- a/DiscImageChef.Filesystems/FFS.cs +++ b/DiscImageChef.Filesystems/FFS.cs @@ -44,12 +44,15 @@ namespace DiscImageChef.Filesystems { Name = "BSD Fast File System (aka UNIX File System, UFS)"; PluginUUID = new Guid("CC90D342-05DB-48A8-988C-C1FE000034A3"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public FFSPlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public FFSPlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "BSD Fast File System (aka UNIX File System, UFS)"; PluginUUID = new Guid("CC90D342-05DB-48A8-988C-C1FE000034A3"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -324,7 +327,7 @@ namespace DiscImageChef.Filesystems #region UFS1 strings_b = new byte[512]; Array.Copy(ufs_sb_sectors, 0x00D4, strings_b, 0, 512); - ufs_sb.fs_fsmnt_ufs1 = StringHandlers.CToString(strings_b); /// 0x00D4, 512 bytes, name mounted on + ufs_sb.fs_fsmnt_ufs1 = StringHandlers.CToString(strings_b, CurrentEncoding); /// 0x00D4, 512 bytes, name mounted on ufs_sb.fs_cgrotor_ufs1 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x0000); /// 0x02D4 last cg searched ufs_sb.fs_cs_ufs1 = new byte[124]; Array.Copy(ufs_sb_sectors, 0x02D8, ufs_sb.fs_cs_ufs1, 0, 124); /// 0x02D8, 124 bytes, uints, list of fs_cs info buffers @@ -336,10 +339,10 @@ namespace DiscImageChef.Filesystems #region UFS2 strings_b = new byte[468]; Array.Copy(ufs_sb_sectors, 0x00D4, strings_b, 0, 468); - ufs_sb.fs_fsmnt_ufs2 = StringHandlers.CToString(strings_b); /// 0x00D4, 468 bytes, name mounted on + ufs_sb.fs_fsmnt_ufs2 = StringHandlers.CToString(strings_b, CurrentEncoding); /// 0x00D4, 468 bytes, name mounted on strings_b = new byte[32]; Array.Copy(ufs_sb_sectors, 0x02A8, strings_b, 0, 32); - ufs_sb.fs_volname_ufs2 = StringHandlers.CToString(strings_b); /// 0x02A8, 32 bytes, volume name + ufs_sb.fs_volname_ufs2 = StringHandlers.CToString(strings_b, CurrentEncoding); /// 0x02A8, 32 bytes, volume name ufs_sb.fs_swuid_ufs2 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x02C8); /// 0x02C8 system-wide uid ufs_sb.fs_pad_ufs2 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x02D0); /// 0x02D0 due to alignment of fs_swuid ufs_sb.fs_cgrotor_ufs2 = BigEndianBitConverter.ToUInt32(ufs_sb_sectors, 0x02D4); /// 0x02D4 last cg searched diff --git a/DiscImageChef.Filesystems/Filesystem.cs b/DiscImageChef.Filesystems/Filesystem.cs index 5f8b9abd..517c4abe 100644 --- a/DiscImageChef.Filesystems/Filesystem.cs +++ b/DiscImageChef.Filesystems/Filesystem.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; +using System.Text; namespace DiscImageChef.Filesystems { @@ -45,6 +46,7 @@ namespace DiscImageChef.Filesystems /// Plugin UUID. public Guid PluginUUID; internal Schemas.FileSystemType xmlFSType; + public Encoding CurrentEncoding; /// /// Information about the filesystem as expected by CICM Metadata XML @@ -68,7 +70,8 @@ namespace DiscImageChef.Filesystems /// Image plugin. /// Partition start. /// Partition end. - protected Filesystem(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + /// Which encoding to use for this filesystem. + protected Filesystem(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { } diff --git a/DiscImageChef.Filesystems/HPFS.cs b/DiscImageChef.Filesystems/HPFS.cs index c0f9face..565c950b 100644 --- a/DiscImageChef.Filesystems/HPFS.cs +++ b/DiscImageChef.Filesystems/HPFS.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "OS/2 High Performance File System"; PluginUUID = new Guid("33513B2C-f590-4acb-8bf2-0b1d5e19dec5"); + CurrentEncoding = Encoding.GetEncoding("ibm850"); } - public HPFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public HPFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "OS/2 High Performance File System"; PluginUUID = new Guid("33513B2C-f590-4acb-8bf2-0b1d5e19dec5"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("ibm850"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -108,9 +111,9 @@ namespace DiscImageChef.Filesystems hpfs_bpb.signature = hpfs_bpb_sector[0x02A]; hpfs_bpb.serial_no = BitConverter.ToUInt32(hpfs_bpb_sector, 0x02B); Array.Copy(hpfs_bpb_sector, 0x02F, volume_name, 0, 11); - hpfs_bpb.volume_label = StringHandlers.CToString(volume_name); + hpfs_bpb.volume_label = StringHandlers.CToString(volume_name, CurrentEncoding); Array.Copy(hpfs_bpb_sector, 0x03A, oem_name, 0, 8); - hpfs_bpb.fs_type = StringHandlers.CToString(oem_name); + hpfs_bpb.fs_type = StringHandlers.CToString(oem_name, CurrentEncoding); hpfs_sb.magic1 = BitConverter.ToUInt32(hpfs_sb_sector, 0x000); hpfs_sb.magic2 = BitConverter.ToUInt32(hpfs_sb_sector, 0x004); diff --git a/DiscImageChef.Filesystems/ISO9660.cs b/DiscImageChef.Filesystems/ISO9660.cs index 1dd2194d..f629351f 100644 --- a/DiscImageChef.Filesystems/ISO9660.cs +++ b/DiscImageChef.Filesystems/ISO9660.cs @@ -51,13 +51,15 @@ namespace DiscImageChef.Filesystems { Name = "ISO9660 Filesystem"; PluginUUID = new Guid("d812f4d3-c357-400d-90fd-3b22ef786aa8"); - //alreadyLaunched = false; + CurrentEncoding = Encoding.ASCII; } - public ISO9660Plugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public ISO9660Plugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "ISO9660 Filesystem"; PluginUUID = new Guid("d812f4d3-c357-400d-90fd-3b22ef786aa8"); + if(encoding == null) + CurrentEncoding = Encoding.ASCII; } struct DecodedVolumeDescriptor @@ -109,9 +111,9 @@ namespace DiscImageChef.Filesystems Array.Copy(vd_sector, 0x001 + xa_off, VDMagic, 0, 5); - DicConsole.DebugWriteLine("ISO9660 plugin", "VDMagic = {0}", Encoding.ASCII.GetString(VDMagic)); + DicConsole.DebugWriteLine("ISO9660 plugin", "VDMagic = {0}", CurrentEncoding.GetString(VDMagic)); - return Encoding.ASCII.GetString(VDMagic) == "CD001"; + return CurrentEncoding.GetString(VDMagic) == "CD001"; } public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, out string information) @@ -189,7 +191,7 @@ namespace DiscImageChef.Filesystems Array.Copy(vd_sector, 0x001, VDMagic, 0, 5); - if(Encoding.ASCII.GetString(VDMagic) != "CD001") // Recognized, it is an ISO9660, now check for rest of data. + if(CurrentEncoding.GetString(VDMagic) != "CD001") // Recognized, it is an ISO9660, now check for rest of data. { if(counter == 0) return; @@ -206,7 +208,7 @@ namespace DiscImageChef.Filesystems // Read to boot system identifier Array.Copy(vd_sector, 0x007, BootSysId, 0, 32); - if(Encoding.ASCII.GetString(BootSysId).Substring(0, 23) == "EL TORITO SPECIFICATION") + if(CurrentEncoding.GetString(BootSysId).Substring(0, 23) == "EL TORITO SPECIFICATION") BootSpec = "El Torito"; break; @@ -299,10 +301,10 @@ namespace DiscImageChef.Filesystems byte[] RRMagic = new byte[2]; Array.Copy(root_dir, 0x22, SUSPMagic, 0, 2); - if(Encoding.ASCII.GetString(SUSPMagic) == "SP") + if(CurrentEncoding.GetString(SUSPMagic) == "SP") { Array.Copy(root_dir, 0x29, RRMagic, 0, 2); - RockRidge |= Encoding.ASCII.GetString(RRMagic) == "RR"; + RockRidge |= CurrentEncoding.GetString(RRMagic) == "RR"; } } @@ -317,9 +319,9 @@ namespace DiscImageChef.Filesystems byte[] ipbin_sector = imagePlugin.ReadSector(0 + partitionStart); Array.Copy(ipbin_sector, 0x000, SegaHardwareID, 0, 16); - DicConsole.DebugWriteLine("ISO9660 plugin", "SegaHardwareID = \"{0}\"", Encoding.ASCII.GetString(SegaHardwareID)); + DicConsole.DebugWriteLine("ISO9660 plugin", "SegaHardwareID = \"{0}\"", CurrentEncoding.GetString(SegaHardwareID)); - switch(Encoding.ASCII.GetString(SegaHardwareID)) + switch(CurrentEncoding.GetString(SegaHardwareID)) { case "SEGADISCSYSTEM ": case "SEGADATADISC ": @@ -388,7 +390,7 @@ namespace DiscImageChef.Filesystems Array.Copy(ipbin_sector, 0x060, system_reserved, 0, 160); // System Reserved Area Array.Copy(ipbin_sector, 0x100, hardware_id, 0, 16); // Hardware ID Array.Copy(ipbin_sector, 0x110, copyright, 0, 3); // "(C)" -- Can be the developer code directly!, if that is the code release date will be displaced - if(Encoding.ASCII.GetString(copyright) == "(C)") + if(CurrentEncoding.GetString(copyright) == "(C)") Array.Copy(ipbin_sector, 0x113, developer_code, 0, 5); // "SEGA" or "T-xx" else Array.Copy(ipbin_sector, 0x110, developer_code, 0, 5); // "SEGA" or "T-xx" @@ -403,9 +405,9 @@ namespace DiscImageChef.Filesystems Array.Copy(ipbin_sector, 0x1B0, spare_space7, 0, 64); // Inside here should be modem information, but I need to get a modem-enabled game Array.Copy(ipbin_sector, 0x1F0, region_codes, 0, 16); // Region codes, space-filled - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.volume_name = \"{0}\"", Encoding.ASCII.GetString(volume_name)); - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.system_name = \"{0}\"", Encoding.ASCII.GetString(system_name)); - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.volume_version = \"{0}\"", Encoding.ASCII.GetString(volume_version)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.volume_name = \"{0}\"", CurrentEncoding.GetString(volume_name)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.system_name = \"{0}\"", CurrentEncoding.GetString(system_name)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.volume_version = \"{0}\"", CurrentEncoding.GetString(volume_version)); DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.volume_type = 0x{0}", BitConverter.ToInt16(volume_type, 0).ToString("X")); DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.system_version = 0x{0}", BitConverter.ToInt16(system_version, 0).ToString("X")); DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.ip_address = 0x{0}", BitConverter.ToInt32(ip_address, 0).ToString("X")); @@ -416,27 +418,27 @@ namespace DiscImageChef.Filesystems DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.sp_loadsize = {0}", BitConverter.ToInt32(sp_loadsize, 0)); DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.sp_entry_address = 0x{0}", BitConverter.ToInt32(sp_entry_address, 0).ToString("X")); DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.sp_work_ram_size = {0}", BitConverter.ToInt32(sp_work_ram_size, 0)); - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.release_date = \"{0}\"", Encoding.ASCII.GetString(release_date)); - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.release_date2 = \"{0}\"", Encoding.ASCII.GetString(release_date2)); - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.developer_code = \"{0}\"", Encoding.ASCII.GetString(developer_code)); - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.domestic_title = \"{0}\"", Encoding.ASCII.GetString(domestic_title)); - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.overseas_title = \"{0}\"", Encoding.ASCII.GetString(overseas_title)); - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.product_code = \"{0}\"", Encoding.ASCII.GetString(product_code)); - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.peripherals = \"{0}\"", Encoding.ASCII.GetString(peripherals)); - DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.region_codes = \"{0}\"", Encoding.ASCII.GetString(region_codes)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.release_date = \"{0}\"", CurrentEncoding.GetString(release_date)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.release_date2 = \"{0}\"", CurrentEncoding.GetString(release_date2)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.developer_code = \"{0}\"", CurrentEncoding.GetString(developer_code)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.domestic_title = \"{0}\"", CurrentEncoding.GetString(domestic_title)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.overseas_title = \"{0}\"", CurrentEncoding.GetString(overseas_title)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.product_code = \"{0}\"", CurrentEncoding.GetString(product_code)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.peripherals = \"{0}\"", CurrentEncoding.GetString(peripherals)); + DicConsole.DebugWriteLine("ISO9660 plugin", "segacd_ipbin.region_codes = \"{0}\"", CurrentEncoding.GetString(region_codes)); // Decoding all data DateTime ipbindate = DateTime.MinValue; CultureInfo provider = CultureInfo.InvariantCulture; try { - ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date), "MMddyyyy", provider); + ipbindate = DateTime.ParseExact(CurrentEncoding.GetString(release_date), "MMddyyyy", provider); } catch { try { - ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date2), "yyyy.MMM", provider); + ipbindate = DateTime.ParseExact(CurrentEncoding.GetString(release_date2), "yyyy.MMM", provider); } #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch { } @@ -444,7 +446,7 @@ namespace DiscImageChef.Filesystems } /* - switch (Encoding.ASCII.GetString(application_type)) + switch (CurrentEncoding.GetString(application_type)) { case "GM": IPBinInformation.AppendLine("Disc is a game."); @@ -458,11 +460,11 @@ namespace DiscImageChef.Filesystems } */ - IPBinInformation.AppendFormat("Volume name: {0}", Encoding.ASCII.GetString(volume_name)).AppendLine(); - //IPBinInformation.AppendFormat("Volume version: {0}", Encoding.ASCII.GetString(volume_version)).AppendLine(); - //IPBinInformation.AppendFormat("{0}", Encoding.ASCII.GetString(volume_type)).AppendLine(); - IPBinInformation.AppendFormat("System name: {0}", Encoding.ASCII.GetString(system_name)).AppendLine(); - //IPBinInformation.AppendFormat("System version: {0}", Encoding.ASCII.GetString(system_version)).AppendLine(); + IPBinInformation.AppendFormat("Volume name: {0}", CurrentEncoding.GetString(volume_name)).AppendLine(); + //IPBinInformation.AppendFormat("Volume version: {0}", CurrentEncoding.GetString(volume_version)).AppendLine(); + //IPBinInformation.AppendFormat("{0}", CurrentEncoding.GetString(volume_type)).AppendLine(); + IPBinInformation.AppendFormat("System name: {0}", CurrentEncoding.GetString(system_name)).AppendLine(); + //IPBinInformation.AppendFormat("System version: {0}", CurrentEncoding.GetString(system_version)).AppendLine(); IPBinInformation.AppendFormat("Initial program address: 0x{0}", BitConverter.ToInt32(ip_address, 0).ToString("X")).AppendLine(); IPBinInformation.AppendFormat("Initial program load size: {0} bytes", BitConverter.ToInt32(ip_loadsize, 0)).AppendLine(); IPBinInformation.AppendFormat("Initial program entry address: 0x{0}", BitConverter.ToInt32(ip_entry_address, 0).ToString("X")).AppendLine(); @@ -473,12 +475,12 @@ namespace DiscImageChef.Filesystems IPBinInformation.AppendFormat("System program work RAM: {0} bytes", BitConverter.ToInt32(sp_work_ram_size, 0)).AppendLine(); if(ipbindate != DateTime.MinValue) IPBinInformation.AppendFormat("Release date: {0}", ipbindate).AppendLine(); - //IPBinInformation.AppendFormat("Release date (other format): {0}", Encoding.ASCII.GetString(release_date2)).AppendLine(); - IPBinInformation.AppendFormat("Hardware ID: {0}", Encoding.ASCII.GetString(hardware_id)).AppendLine(); - IPBinInformation.AppendFormat("Developer code: {0}", Encoding.ASCII.GetString(developer_code)).AppendLine(); - IPBinInformation.AppendFormat("Domestic title: {0}", Encoding.ASCII.GetString(domestic_title)).AppendLine(); - IPBinInformation.AppendFormat("Overseas title: {0}", Encoding.ASCII.GetString(overseas_title)).AppendLine(); - IPBinInformation.AppendFormat("Product code: {0}", Encoding.ASCII.GetString(product_code)).AppendLine(); + //IPBinInformation.AppendFormat("Release date (other format): {0}", CurrentEncoding.GetString(release_date2)).AppendLine(); + IPBinInformation.AppendFormat("Hardware ID: {0}", CurrentEncoding.GetString(hardware_id)).AppendLine(); + IPBinInformation.AppendFormat("Developer code: {0}", CurrentEncoding.GetString(developer_code)).AppendLine(); + IPBinInformation.AppendFormat("Domestic title: {0}", CurrentEncoding.GetString(domestic_title)).AppendLine(); + IPBinInformation.AppendFormat("Overseas title: {0}", CurrentEncoding.GetString(overseas_title)).AppendLine(); + IPBinInformation.AppendFormat("Product code: {0}", CurrentEncoding.GetString(product_code)).AppendLine(); IPBinInformation.AppendFormat("Peripherals:").AppendLine(); foreach(byte peripheral in peripherals) { @@ -585,29 +587,29 @@ namespace DiscImageChef.Filesystems Array.Copy(ipbin_sector, 0x050, peripherals, 0, 16); // Supported peripherals, see above Array.Copy(ipbin_sector, 0x060, product_name, 0, 112); // Game name, space-filled - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.maker_id = \"{0}\"", Encoding.ASCII.GetString(maker_id)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.product_no = \"{0}\"", Encoding.ASCII.GetString(product_no)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.product_version = \"{0}\"", Encoding.ASCII.GetString(product_version)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.release_datedate = \"{0}\"", Encoding.ASCII.GetString(release_date)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.saturn_media = \"{0}\"", Encoding.ASCII.GetString(saturn_media)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_no = {0}", Encoding.ASCII.GetString(disc_no)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_no_separator = \"{0}\"", Encoding.ASCII.GetString(disc_no_separator)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_total_nos = {0}", Encoding.ASCII.GetString(disc_total_nos)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.release_date = \"{0}\"", Encoding.ASCII.GetString(release_date)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.spare_space1 = \"{0}\"", Encoding.ASCII.GetString(spare_space1)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.region_codes = \"{0}\"", Encoding.ASCII.GetString(region_codes)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.peripherals = \"{0}\"", Encoding.ASCII.GetString(peripherals)); - DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.product_name = \"{0}\"", Encoding.ASCII.GetString(product_name)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.maker_id = \"{0}\"", CurrentEncoding.GetString(maker_id)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.product_no = \"{0}\"", CurrentEncoding.GetString(product_no)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.product_version = \"{0}\"", CurrentEncoding.GetString(product_version)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.release_datedate = \"{0}\"", CurrentEncoding.GetString(release_date)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.saturn_media = \"{0}\"", CurrentEncoding.GetString(saturn_media)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_no = {0}", CurrentEncoding.GetString(disc_no)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_no_separator = \"{0}\"", CurrentEncoding.GetString(disc_no_separator)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.disc_total_nos = {0}", CurrentEncoding.GetString(disc_total_nos)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.release_date = \"{0}\"", CurrentEncoding.GetString(release_date)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.spare_space1 = \"{0}\"", CurrentEncoding.GetString(spare_space1)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.region_codes = \"{0}\"", CurrentEncoding.GetString(region_codes)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.peripherals = \"{0}\"", CurrentEncoding.GetString(peripherals)); + DicConsole.DebugWriteLine("ISO9660 plugin", "saturn_ipbin.product_name = \"{0}\"", CurrentEncoding.GetString(product_name)); // Decoding all data DateTime ipbindate; CultureInfo provider = CultureInfo.InvariantCulture; - ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date), "yyyyMMdd", provider); - IPBinInformation.AppendFormat("Product name: {0}", Encoding.ASCII.GetString(product_name)).AppendLine(); - IPBinInformation.AppendFormat("Product number: {0}", Encoding.ASCII.GetString(product_no)).AppendLine(); - IPBinInformation.AppendFormat("Product version: {0}", Encoding.ASCII.GetString(product_version)).AppendLine(); + ipbindate = DateTime.ParseExact(CurrentEncoding.GetString(release_date), "yyyyMMdd", provider); + IPBinInformation.AppendFormat("Product name: {0}", CurrentEncoding.GetString(product_name)).AppendLine(); + IPBinInformation.AppendFormat("Product number: {0}", CurrentEncoding.GetString(product_no)).AppendLine(); + IPBinInformation.AppendFormat("Product version: {0}", CurrentEncoding.GetString(product_version)).AppendLine(); IPBinInformation.AppendFormat("Release date: {0}", ipbindate).AppendLine(); - IPBinInformation.AppendFormat("Disc number {0} of {1}", Encoding.ASCII.GetString(disc_no), Encoding.ASCII.GetString(disc_total_nos)).AppendLine(); + IPBinInformation.AppendFormat("Disc number {0} of {1}", CurrentEncoding.GetString(disc_no), CurrentEncoding.GetString(disc_total_nos)).AppendLine(); IPBinInformation.AppendFormat("Peripherals:").AppendLine(); foreach(byte peripheral in peripherals) @@ -713,35 +715,35 @@ namespace DiscImageChef.Filesystems Array.Copy(ipbin_sector, 0x070, producer, 0, 16); // Game producer, space-filled Array.Copy(ipbin_sector, 0x080, product_name, 0, 128); // Game name, space-filled - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.maker_id = \"{0}\"", Encoding.ASCII.GetString(maker_id)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.dreamcast_crc = 0x{0}", Encoding.ASCII.GetString(dreamcast_crc)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.spare_space1 = \"{0}\"", Encoding.ASCII.GetString(spare_space1)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.dreamcast_media = \"{0}\"", Encoding.ASCII.GetString(dreamcast_media)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.disc_no = {0}", Encoding.ASCII.GetString(disc_no)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.disc_no_separator = \"{0}\"", Encoding.ASCII.GetString(disc_no_separator)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.disc_total_nos = \"{0}\"", Encoding.ASCII.GetString(disc_total_nos)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.spare_space2 = \"{0}\"", Encoding.ASCII.GetString(spare_space2)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.region_codes = \"{0}\"", Encoding.ASCII.GetString(region_codes)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.peripherals = \"{0}\"", Encoding.ASCII.GetString(peripherals)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.product_no = \"{0}\"", Encoding.ASCII.GetString(product_no)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.product_version = \"{0}\"", Encoding.ASCII.GetString(product_version)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.release_date = \"{0}\"", Encoding.ASCII.GetString(release_date)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.spare_space3 = \"{0}\"", Encoding.ASCII.GetString(spare_space3)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.boot_filename = \"{0}\"", Encoding.ASCII.GetString(boot_filename)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.producer = \"{0}\"", Encoding.ASCII.GetString(producer)); - DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.product_name = \"{0}\"", Encoding.ASCII.GetString(product_name)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.maker_id = \"{0}\"", CurrentEncoding.GetString(maker_id)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.dreamcast_crc = 0x{0}", CurrentEncoding.GetString(dreamcast_crc)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.spare_space1 = \"{0}\"", CurrentEncoding.GetString(spare_space1)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.dreamcast_media = \"{0}\"", CurrentEncoding.GetString(dreamcast_media)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.disc_no = {0}", CurrentEncoding.GetString(disc_no)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.disc_no_separator = \"{0}\"", CurrentEncoding.GetString(disc_no_separator)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.disc_total_nos = \"{0}\"", CurrentEncoding.GetString(disc_total_nos)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.spare_space2 = \"{0}\"", CurrentEncoding.GetString(spare_space2)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.region_codes = \"{0}\"", CurrentEncoding.GetString(region_codes)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.peripherals = \"{0}\"", CurrentEncoding.GetString(peripherals)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.product_no = \"{0}\"", CurrentEncoding.GetString(product_no)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.product_version = \"{0}\"", CurrentEncoding.GetString(product_version)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.release_date = \"{0}\"", CurrentEncoding.GetString(release_date)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.spare_space3 = \"{0}\"", CurrentEncoding.GetString(spare_space3)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.boot_filename = \"{0}\"", CurrentEncoding.GetString(boot_filename)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.producer = \"{0}\"", CurrentEncoding.GetString(producer)); + DicConsole.DebugWriteLine("ISO9660 plugin", "dreamcast_ipbin.product_name = \"{0}\"", CurrentEncoding.GetString(product_name)); // Decoding all data DateTime ipbindate; CultureInfo provider = CultureInfo.InvariantCulture; - ipbindate = DateTime.ParseExact(Encoding.ASCII.GetString(release_date), "yyyyMMdd", provider); - IPBinInformation.AppendFormat("Product name: {0}", Encoding.ASCII.GetString(product_name)).AppendLine(); - IPBinInformation.AppendFormat("Product version: {0}", Encoding.ASCII.GetString(product_version)).AppendLine(); - IPBinInformation.AppendFormat("Producer: {0}", Encoding.ASCII.GetString(producer)).AppendLine(); - IPBinInformation.AppendFormat("Disc media: {0}", Encoding.ASCII.GetString(dreamcast_media)).AppendLine(); - IPBinInformation.AppendFormat("Disc number {0} of {1}", Encoding.ASCII.GetString(disc_no), Encoding.ASCII.GetString(disc_total_nos)).AppendLine(); + ipbindate = DateTime.ParseExact(CurrentEncoding.GetString(release_date), "yyyyMMdd", provider); + IPBinInformation.AppendFormat("Product name: {0}", CurrentEncoding.GetString(product_name)).AppendLine(); + IPBinInformation.AppendFormat("Product version: {0}", CurrentEncoding.GetString(product_version)).AppendLine(); + IPBinInformation.AppendFormat("Producer: {0}", CurrentEncoding.GetString(producer)).AppendLine(); + IPBinInformation.AppendFormat("Disc media: {0}", CurrentEncoding.GetString(dreamcast_media)).AppendLine(); + IPBinInformation.AppendFormat("Disc number {0} of {1}", CurrentEncoding.GetString(disc_no), CurrentEncoding.GetString(disc_total_nos)).AppendLine(); IPBinInformation.AppendFormat("Release date: {0}", ipbindate).AppendLine(); - switch(Encoding.ASCII.GetString(boot_filename)) + switch(CurrentEncoding.GetString(boot_filename)) { case "1ST_READ.BIN": IPBinInformation.AppendLine("Disc boots natively."); @@ -750,7 +752,7 @@ namespace DiscImageChef.Filesystems IPBinInformation.AppendLine("Disc boots using Windows CE."); break; default: - IPBinInformation.AppendFormat("Disc boots using unknown loader: {0}.", Encoding.ASCII.GetString(boot_filename)).AppendLine(); + IPBinInformation.AppendFormat("Disc boots using unknown loader: {0}.", CurrentEncoding.GetString(boot_filename)).AppendLine(); break; } IPBinInformation.AppendLine("Regions supported:"); @@ -775,7 +777,7 @@ namespace DiscImageChef.Filesystems } } - int iPeripherals = int.Parse(Encoding.ASCII.GetString(peripherals), NumberStyles.HexNumber); + int iPeripherals = int.Parse(CurrentEncoding.GetString(peripherals), NumberStyles.HexNumber); if((iPeripherals & 0x00000001) == 0x00000001) IPBinInformation.AppendLine("Game uses Windows CE."); diff --git a/DiscImageChef.Filesystems/JFS.cs b/DiscImageChef.Filesystems/JFS.cs index d34d8478..14f90ed4 100644 --- a/DiscImageChef.Filesystems/JFS.cs +++ b/DiscImageChef.Filesystems/JFS.cs @@ -137,12 +137,15 @@ namespace DiscImageChef.Filesystems { Name = "JFS Plugin"; PluginUUID = new Guid("D3BE2A41-8F28-4055-94DC-BB6C72A0E9C4"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public JFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public JFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "JFS Plugin"; PluginUUID = new Guid("D3BE2A41-8F28-4055-94DC-BB6C72A0E9C4"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -231,9 +234,9 @@ namespace DiscImageChef.Filesystems sb.AppendLine("Volume is dirty"); sb.AppendFormat("Volume was last updated on {0}", DateHandlers.UNIXUnsignedToDateTime(jfsSb.s_time.tv_sec, jfsSb.s_time.tv_nsec)).AppendLine(); if(jfsSb.s_version == 1) - sb.AppendFormat("Volume name: {0}", Encoding.ASCII.GetString(jfsSb.s_fpack)).AppendLine(); + sb.AppendFormat("Volume name: {0}", CurrentEncoding.GetString(jfsSb.s_fpack)).AppendLine(); else - sb.AppendFormat("Volume name: {0}", Encoding.ASCII.GetString(jfsSb.s_label)).AppendLine(); + sb.AppendFormat("Volume name: {0}", CurrentEncoding.GetString(jfsSb.s_label)).AppendLine(); sb.AppendFormat("Volume UUID: {0}", jfsSb.s_uuid).AppendLine(); xmlFSType = new Schemas.FileSystemType(); @@ -242,9 +245,9 @@ namespace DiscImageChef.Filesystems xmlFSType.ClusterSize = (int)jfsSb.s_bsize; xmlFSType.Bootable = true; if(jfsSb.s_version == 1) - xmlFSType.VolumeName = Encoding.ASCII.GetString(jfsSb.s_fpack); + xmlFSType.VolumeName = CurrentEncoding.GetString(jfsSb.s_fpack); else - xmlFSType.VolumeName = Encoding.ASCII.GetString(jfsSb.s_label); + xmlFSType.VolumeName = CurrentEncoding.GetString(jfsSb.s_label); xmlFSType.VolumeSerial = string.Format("{0}", jfsSb.s_uuid); xmlFSType.ModificationDate = DateHandlers.UNIXUnsignedToDateTime(jfsSb.s_time.tv_sec, jfsSb.s_time.tv_nsec); xmlFSType.ModificationDateSpecified = true; diff --git a/DiscImageChef.Filesystems/LisaFS/Dir.cs b/DiscImageChef.Filesystems/LisaFS/Dir.cs index 8a5c721d..2b67812e 100644 --- a/DiscImageChef.Filesystems/LisaFS/Dir.cs +++ b/DiscImageChef.Filesystems/LisaFS/Dir.cs @@ -97,7 +97,7 @@ namespace DiscImageChef.Filesystems.LisaFS if(entry.parentID == dirId) // Do same trick as Mac OS X, replace filesystem '/' with '-', // as '-' is the path separator in Lisa OS - contents.Add(GetString(entry.filename).Replace('/', '-')); + contents.Add(CurrentEncoding.GetString(entry.filename).Replace('/', '-')); } return Errno.NoError; diff --git a/DiscImageChef.Filesystems/LisaFS/Encoding.cs b/DiscImageChef.Filesystems/LisaFS/Encoding.cs index 8a3701a3..7b9fdac8 100644 --- a/DiscImageChef.Filesystems/LisaFS/Encoding.cs +++ b/DiscImageChef.Filesystems/LisaFS/Encoding.cs @@ -34,7 +34,7 @@ namespace DiscImageChef.Filesystems.LisaFS { partial class LisaFS : Filesystem { - /// + /* /// /// The Lisa to Unicode character map. /// MacRoman is a superset of LisaRoman. /// @@ -158,7 +158,7 @@ namespace DiscImageChef.Filesystems.LisaFS } return uni; - } + }*/ } } diff --git a/DiscImageChef.Filesystems/LisaFS/Extent.cs b/DiscImageChef.Filesystems/LisaFS/Extent.cs index 9dbe50bc..4cba6b1b 100644 --- a/DiscImageChef.Filesystems/LisaFS/Extent.cs +++ b/DiscImageChef.Filesystems/LisaFS/Extent.cs @@ -196,7 +196,7 @@ namespace DiscImageChef.Filesystems.LisaFS if(!printedExtents.Contains(fileId)) { DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filenameLen = {1}", fileId, file.filenameLen); - DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filename = {1}", fileId, GetString(file.filename)); + DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].filename = {1}", fileId, CurrentEncoding.GetString(file.filename)); DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown1 = 0x{1:X4}", fileId, file.unknown1); DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].file_uid = 0x{1:X16}", fileId, file.file_uid); DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown2 = 0x{1:X2}", fileId, file.unknown2); @@ -226,7 +226,7 @@ namespace DiscImageChef.Filesystems.LisaFS DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].revision = {1}", fileId, file.revision); DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown6 = 0x{1:X4}", fileId, file.unknown6); DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].password_valid = {1}", fileId, file.password_valid > 0); - DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].password = {1}", fileId, GetString(file.password)); + DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].password = {1}", fileId, CurrentEncoding.GetString(file.password)); DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].unknown7 = 0x{1:X2}{2:X2}{3:X2}", fileId, file.unknown7[0], file.unknown7[1], file.unknown7[2]); DicConsole.DebugWriteLine("LisaFS plugin", "ExtentFile[{0}].overhead = {1}", fileId, file.overhead); diff --git a/DiscImageChef.Filesystems/LisaFS/File.cs b/DiscImageChef.Filesystems/LisaFS/File.cs index 1668d45e..a0b467d3 100644 --- a/DiscImageChef.Filesystems/LisaFS/File.cs +++ b/DiscImageChef.Filesystems/LisaFS/File.cs @@ -504,7 +504,7 @@ namespace DiscImageChef.Filesystems.LisaFS foreach(CatalogEntry entry in catalogCache) { - string filename = GetString(entry.filename); + string filename = CurrentEncoding.GetString(entry.filename); // LisaOS is case insensitive if(string.Compare(wantedFilename, filename, StringComparison.InvariantCultureIgnoreCase) == 0 diff --git a/DiscImageChef.Filesystems/LisaFS/Info.cs b/DiscImageChef.Filesystems/LisaFS/Info.cs index dbc13ac8..d259f806 100644 --- a/DiscImageChef.Filesystems/LisaFS/Info.cs +++ b/DiscImageChef.Filesystems/LisaFS/Info.cs @@ -170,12 +170,12 @@ namespace DiscImageChef.Filesystems.LisaFS info_mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); info_mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A); Array.Copy(sector, 0x0C, pString, 0, 33); - info_mddf.volname = GetStringFromPascal(pString); + info_mddf.volname = StringHandlers.PascalToString(pString, CurrentEncoding); info_mddf.unknown1 = sector[0x2D]; Array.Copy(sector, 0x2E, pString, 0, 33); // Prevent garbage if(pString[0] <= 32) - info_mddf.password = GetStringFromPascal(pString); + info_mddf.password = StringHandlers.PascalToString(pString, CurrentEncoding); else info_mddf.password = ""; info_mddf.unknown2 = sector[0x4F]; diff --git a/DiscImageChef.Filesystems/LisaFS/LisaFS.cs b/DiscImageChef.Filesystems/LisaFS/LisaFS.cs index 2b26164f..cd4c4fc6 100644 --- a/DiscImageChef.Filesystems/LisaFS/LisaFS.cs +++ b/DiscImageChef.Filesystems/LisaFS/LisaFS.cs @@ -33,6 +33,7 @@ using System; using System.Collections.Generic; +using System.Text; using DiscImageChef.ImagePlugins; namespace DiscImageChef.Filesystems.LisaFS @@ -71,13 +72,15 @@ namespace DiscImageChef.Filesystems.LisaFS { Name = "Apple Lisa File System"; PluginUUID = new Guid("7E6034D1-D823-4248-A54D-239742B28391"); + CurrentEncoding = new Claunia.Encoding.LisaRoman(); } - public LisaFS(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public LisaFS(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { device = imagePlugin; Name = "Apple Lisa File System"; PluginUUID = new Guid("7E6034D1-D823-4248-A54D-239742B28391"); + CurrentEncoding = new Claunia.Encoding.LisaRoman(); } } } diff --git a/DiscImageChef.Filesystems/LisaFS/Super.cs b/DiscImageChef.Filesystems/LisaFS/Super.cs index 6521751b..e5e5aedc 100644 --- a/DiscImageChef.Filesystems/LisaFS/Super.cs +++ b/DiscImageChef.Filesystems/LisaFS/Super.cs @@ -102,12 +102,12 @@ namespace DiscImageChef.Filesystems.LisaFS mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02); mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A); Array.Copy(sector, 0x0C, pString, 0, 33); - mddf.volname = GetStringFromPascal(pString); + mddf.volname = StringHandlers.PascalToString(pString, CurrentEncoding); mddf.unknown1 = sector[0x2D]; Array.Copy(sector, 0x2E, pString, 0, 33); // Prevent garbage if(pString[0] <= 32) - mddf.password = GetStringFromPascal(pString); + mddf.password = StringHandlers.PascalToString(pString, CurrentEncoding); else mddf.password = ""; mddf.unknown2 = sector[0x4F]; diff --git a/DiscImageChef.Filesystems/MinixFS.cs b/DiscImageChef.Filesystems/MinixFS.cs index b0752bfc..51197db1 100644 --- a/DiscImageChef.Filesystems/MinixFS.cs +++ b/DiscImageChef.Filesystems/MinixFS.cs @@ -65,12 +65,15 @@ namespace DiscImageChef.Filesystems { Name = "Minix Filesystem"; PluginUUID = new Guid("FE248C3B-B727-4AE5-A39F-79EA9A07D4B3"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public MinixFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public MinixFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Minix Filesystem"; PluginUUID = new Guid("FE248C3B-B727-4AE5-A39F-79EA9A07D4B3"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filesystems/NILFS2.cs b/DiscImageChef.Filesystems/NILFS2.cs index 2922093c..1b9fe873 100644 --- a/DiscImageChef.Filesystems/NILFS2.cs +++ b/DiscImageChef.Filesystems/NILFS2.cs @@ -100,12 +100,15 @@ namespace DiscImageChef.Filesystems { Name = "NILFS2 Plugin"; PluginUUID = new Guid("35224226-C5CC-48B5-8FFD-3781E91E86B6"); + CurrentEncoding = Encoding.UTF8; } - public NILFS2(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public NILFS2(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "NILFS2 Plugin"; PluginUUID = new Guid("35224226-C5CC-48B5-8FFD-3781E91E86B6"); + if(encoding == null) + CurrentEncoding = Encoding.UTF8; } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -177,7 +180,7 @@ namespace DiscImageChef.Filesystems sb.AppendFormat("Creator OS code: {0}", nilfsSb.creator_os).AppendLine(); sb.AppendFormat("{0} bytes per inode", nilfsSb.inode_size).AppendLine(); sb.AppendFormat("Volume UUID: {0}", nilfsSb.uuid).AppendLine(); - sb.AppendFormat("Volume name: {0}", Encoding.ASCII.GetString(nilfsSb.volume_name)).AppendLine(); + sb.AppendFormat("Volume name: {0}", CurrentEncoding.GetString(nilfsSb.volume_name)).AppendLine(); sb.AppendFormat("Volume created on {0}", DateHandlers.UNIXUnsignedToDateTime(nilfsSb.ctime)).AppendLine(); sb.AppendFormat("Volume last mounted on {0}", DateHandlers.UNIXUnsignedToDateTime(nilfsSb.mtime)).AppendLine(); sb.AppendFormat("Volume last written on {0}", DateHandlers.UNIXUnsignedToDateTime(nilfsSb.wtime)).AppendLine(); @@ -190,7 +193,7 @@ namespace DiscImageChef.Filesystems xmlFSType.SystemIdentifier = "Linux"; xmlFSType.ClusterSize = 1 << (int)(nilfsSb.log_block_size + 10); xmlFSType.Clusters = (long)nilfsSb.dev_size / xmlFSType.ClusterSize; - xmlFSType.VolumeName = Encoding.Unicode.GetString(nilfsSb.volume_name); + xmlFSType.VolumeName = CurrentEncoding.GetString(nilfsSb.volume_name); xmlFSType.VolumeSerial = nilfsSb.uuid.ToString(); xmlFSType.CreationDate = DateHandlers.UNIXUnsignedToDateTime(nilfsSb.ctime); xmlFSType.CreationDateSpecified = true; diff --git a/DiscImageChef.Filesystems/NTFS.cs b/DiscImageChef.Filesystems/NTFS.cs index 7d3aa149..8e2f58ae 100644 --- a/DiscImageChef.Filesystems/NTFS.cs +++ b/DiscImageChef.Filesystems/NTFS.cs @@ -44,12 +44,14 @@ namespace DiscImageChef.Filesystems { Name = "New Technology File System (NTFS)"; PluginUUID = new Guid("33513B2C-1e6d-4d21-a660-0bbc789c3871"); + CurrentEncoding = Encoding.Unicode; } - public NTFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public NTFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "New Technology File System (NTFS)"; PluginUUID = new Guid("33513B2C-1e6d-4d21-a660-0bbc789c3871"); + CurrentEncoding = Encoding.Unicode; } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filesystems/Nintendo.cs b/DiscImageChef.Filesystems/Nintendo.cs index 435f56d6..715a1af5 100644 --- a/DiscImageChef.Filesystems/Nintendo.cs +++ b/DiscImageChef.Filesystems/Nintendo.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "Nintendo optical filesystems"; PluginUUID = new Guid("4675fcb4-4418-4288-9e4a-33d6a4ac1126"); + CurrentEncoding = Encoding.GetEncoding("shift_jis"); } - public NintendoPlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public NintendoPlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Nintendo optical filesystems"; PluginUUID = new Guid("4675fcb4-4418-4288-9e4a-33d6a4ac1126"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("shift_jis"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -106,7 +109,7 @@ namespace DiscImageChef.Filesystems fields.streamBufferSize = header[9]; byte[] temp = new byte[64]; Array.Copy(header, 0x20, temp, 0, 64); - fields.title = StringHandlers.CToString(temp); + fields.title = StringHandlers.CToString(temp, CurrentEncoding); if(!wii) { diff --git a/DiscImageChef.Filesystems/ODS.cs b/DiscImageChef.Filesystems/ODS.cs index 53f6128f..ac760385 100644 --- a/DiscImageChef.Filesystems/ODS.cs +++ b/DiscImageChef.Filesystems/ODS.cs @@ -51,12 +51,15 @@ namespace DiscImageChef.Filesystems { Name = "Files-11 On-Disk Structure"; PluginUUID = new Guid("de20633c-8021-4384-aeb0-83b0df14491f"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } - public ODS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public ODS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Files-11 On-Disk Structure"; PluginUUID = new Guid("de20633c-8021-4384-aeb0-83b0df14491f"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -129,13 +132,13 @@ namespace DiscImageChef.Filesystems homeblock.copydate = BitConverter.ToUInt64(hb_sector, 0x092); homeblock.serialnum = BitConverter.ToUInt32(hb_sector, 0x1C8); Array.Copy(hb_sector, 0x1CC, temp_string, 0, 12); - homeblock.strucname = StringHandlers.CToString(temp_string); + homeblock.strucname = StringHandlers.CToString(temp_string, CurrentEncoding); Array.Copy(hb_sector, 0x1D8, temp_string, 0, 12); - homeblock.volname = StringHandlers.CToString(temp_string); + homeblock.volname = StringHandlers.CToString(temp_string, CurrentEncoding); Array.Copy(hb_sector, 0x1E4, temp_string, 0, 12); - homeblock.ownername = StringHandlers.CToString(temp_string); + homeblock.ownername = StringHandlers.CToString(temp_string, CurrentEncoding); Array.Copy(hb_sector, 0x1F0, temp_string, 0, 12); - homeblock.format = StringHandlers.CToString(temp_string); + homeblock.format = StringHandlers.CToString(temp_string, CurrentEncoding); homeblock.checksum2 = BitConverter.ToUInt16(hb_sector, 0x1FE); if((homeblock.struclev & 0xFF00) != 0x0200 || (homeblock.struclev & 0xFF) != 1 || homeblock.format != "DECFILE11B ") diff --git a/DiscImageChef.Filesystems/Opera.cs b/DiscImageChef.Filesystems/Opera.cs index 383fc59f..40464d21 100644 --- a/DiscImageChef.Filesystems/Opera.cs +++ b/DiscImageChef.Filesystems/Opera.cs @@ -42,12 +42,15 @@ namespace DiscImageChef.Filesystems { Name = "Opera Filesystem Plugin"; PluginUUID = new Guid("0ec84ec7-eae6-4196-83fe-943b3fe46dbd"); + CurrentEncoding = Encoding.ASCII; } - public OperaFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public OperaFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Opera Filesystem Plugin"; PluginUUID = new Guid("0ec84ec7-eae6-4196-83fe-943b3fe46dbd"); + if(encoding == null) // TODO: Find correct default encoding + CurrentEncoding = Encoding.ASCII; } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filesystems/PCEngine.cs b/DiscImageChef.Filesystems/PCEngine.cs index 8b0e0d95..5f5a1af3 100644 --- a/DiscImageChef.Filesystems/PCEngine.cs +++ b/DiscImageChef.Filesystems/PCEngine.cs @@ -42,12 +42,15 @@ namespace DiscImageChef.Filesystems { Name = "PC Engine CD Plugin"; PluginUUID = new Guid("e5ee6d7c-90fa-49bd-ac89-14ef750b8af3"); + CurrentEncoding = Encoding.GetEncoding("shift_jis"); } - public PCEnginePlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public PCEnginePlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "PC Engine CD Plugin"; PluginUUID = new Guid("e5ee6d7c-90fa-49bd-ac89-14ef750b8af3"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("shift_jis"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filesystems/PFS.cs b/DiscImageChef.Filesystems/PFS.cs index 3b129b80..12f654b0 100644 --- a/DiscImageChef.Filesystems/PFS.cs +++ b/DiscImageChef.Filesystems/PFS.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "Professional File System"; PluginUUID = new Guid("68DE769E-D957-406A-8AE4-3781CA8CDA77"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } - public PFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public PFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Professional File System"; PluginUUID = new Guid("68DE769E-D957-406A-8AE4-3781CA8CDA77"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } /// @@ -220,7 +223,7 @@ namespace DiscImageChef.Filesystems sbInformation.AppendLine(); - sbInformation.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(rootBlock.diskname)).AppendLine(); + sbInformation.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(rootBlock.diskname, CurrentEncoding)).AppendLine(); sbInformation.AppendFormat("Volume has {0} free sectors of {1}", rootBlock.blocksfree, rootBlock.diskSize).AppendLine(); sbInformation.AppendFormat("Volume created on {0}", DateHandlers.AmigaToDateTime(rootBlock.creationday, rootBlock.creationminute, rootBlock.creationtick)).AppendLine(); if(rootBlock.extension > 0) @@ -234,7 +237,7 @@ namespace DiscImageChef.Filesystems xmlFSType.FreeClustersSpecified = true; xmlFSType.Clusters = rootBlock.diskSize / imagePlugin.GetSectorSize(); xmlFSType.ClusterSize = (int)imagePlugin.GetSectorSize(); - xmlFSType.VolumeName = StringHandlers.PascalToString(rootBlock.diskname); + xmlFSType.VolumeName = StringHandlers.PascalToString(rootBlock.diskname, CurrentEncoding); } public override Errno Mount() diff --git a/DiscImageChef.Filesystems/ProDOS.cs b/DiscImageChef.Filesystems/ProDOS.cs index 7a08b2c5..d0e4d918 100644 --- a/DiscImageChef.Filesystems/ProDOS.cs +++ b/DiscImageChef.Filesystems/ProDOS.cs @@ -82,12 +82,15 @@ namespace DiscImageChef.Filesystems { Name = "Apple ProDOS filesystem"; PluginUUID = new Guid("43874265-7B8A-4739-BCF7-07F80D5932BF"); + CurrentEncoding = new Claunia.Encoding.LisaRoman(); } - public ProDOSPlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public ProDOSPlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Apple ProDOS filesystem"; PluginUUID = new Guid("43874265-7B8A-4739-BCF7-07F80D5932BF"); + if(encoding == null) // TODO: Until Apple ][ encoding is implemented + CurrentEncoding = new Claunia.Encoding.LisaRoman(); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -149,7 +152,7 @@ namespace DiscImageChef.Filesystems rootDirectoryKeyBlock.header.name_length = (byte)(rootDirectoryKeyBlockBytes[0x04] & ProDOSNameLengthMask); temporal = new byte[rootDirectoryKeyBlock.header.name_length]; Array.Copy(rootDirectoryKeyBlockBytes, 0x05, temporal, 0, rootDirectoryKeyBlock.header.name_length); - rootDirectoryKeyBlock.header.volume_name = Encoding.ASCII.GetString(temporal); + rootDirectoryKeyBlock.header.volume_name = CurrentEncoding.GetString(temporal); rootDirectoryKeyBlock.header.reserved = BitConverter.ToUInt64(rootDirectoryKeyBlockBytes, 0x14); temp_timestamp_left = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1C); diff --git a/DiscImageChef.Filesystems/QNX4.cs b/DiscImageChef.Filesystems/QNX4.cs index b69f6d5c..47b7fa3a 100644 --- a/DiscImageChef.Filesystems/QNX4.cs +++ b/DiscImageChef.Filesystems/QNX4.cs @@ -34,6 +34,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; +using System.Text; namespace DiscImageChef.Filesystems { @@ -110,12 +111,15 @@ namespace DiscImageChef.Filesystems { Name = "QNX4 Plugin"; PluginUUID = new Guid("E73A63FA-B5B0-48BF-BF82-DA5F0A8170D2"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public QNX4(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public QNX4(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "QNX4 Plugin"; PluginUUID = new Guid("E73A63FA-B5B0-48BF-BF82-DA5F0A8170D2"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -173,7 +177,7 @@ namespace DiscImageChef.Filesystems // Too much useless information /* - DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_fname = {0}", Encoding.ASCII.GetString(qnxSb.rootDir.di_fname)); + DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_fname = {0}", CurrentEncoding.GetString(qnxSb.rootDir.di_fname)); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_size = {0}", qnxSb.rootDir.di_size); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_first_xtnt.block = {0}", qnxSb.rootDir.di_first_xtnt.block); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_first_xtnt.length = {0}", qnxSb.rootDir.di_first_xtnt.length); @@ -191,7 +195,7 @@ namespace DiscImageChef.Filesystems DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_type = {0}", qnxSb.rootDir.di_type); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.rootDir.di_status = {0}", qnxSb.rootDir.di_status); - DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_fname = {0}", Encoding.ASCII.GetString(qnxSb.inode.di_fname)); + DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_fname = {0}", CurrentEncoding.GetString(qnxSb.inode.di_fname)); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_size = {0}", qnxSb.inode.di_size); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_first_xtnt.block = {0}", qnxSb.inode.di_first_xtnt.block); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_first_xtnt.length = {0}", qnxSb.inode.di_first_xtnt.length); @@ -209,7 +213,7 @@ namespace DiscImageChef.Filesystems DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_type = {0}", qnxSb.inode.di_type); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.inode.di_status = {0}", qnxSb.inode.di_status); - DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_fname = {0}", Encoding.ASCII.GetString(qnxSb.boot.di_fname)); + DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_fname = {0}", CurrentEncoding.GetString(qnxSb.boot.di_fname)); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_size = {0}", qnxSb.boot.di_size); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_first_xtnt.block = {0}", qnxSb.boot.di_first_xtnt.block); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_first_xtnt.length = {0}", qnxSb.boot.di_first_xtnt.length); @@ -227,7 +231,7 @@ namespace DiscImageChef.Filesystems DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_type = {0}", qnxSb.boot.di_type); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.boot.di_status = {0}", qnxSb.boot.di_status); - DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_fname = {0}", Encoding.ASCII.GetString(qnxSb.altBoot.di_fname)); + DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_fname = {0}", CurrentEncoding.GetString(qnxSb.altBoot.di_fname)); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_size = {0}", qnxSb.altBoot.di_size); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_first_xtnt.block = {0}", qnxSb.altBoot.di_first_xtnt.block); DicConsole.DebugWriteLine("QNX4 plugin", "qnxSb.altBoot.di_first_xtnt.length = {0}", qnxSb.altBoot.di_first_xtnt.length); diff --git a/DiscImageChef.Filesystems/QNX6.cs b/DiscImageChef.Filesystems/QNX6.cs index 8e8692f5..96fc99a6 100644 --- a/DiscImageChef.Filesystems/QNX6.cs +++ b/DiscImageChef.Filesystems/QNX6.cs @@ -106,12 +106,15 @@ namespace DiscImageChef.Filesystems { Name = "QNX6 Plugin"; PluginUUID = new Guid("3E610EA2-4D08-4D70-8947-830CD4C74FC0"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public QNX6(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public QNX6(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "QNX6 Plugin"; PluginUUID = new Guid("3E610EA2-4D08-4D70-8947-830CD4C74FC0"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -184,7 +187,7 @@ namespace DiscImageChef.Filesystems xmlFSType.FilesSpecified = true; xmlFSType.FreeClusters = audiSb.freeBlocks; xmlFSType.FreeClustersSpecified = true; - //xmlFSType.VolumeName = Encoding.ASCII.GetString(audiSb.id); + //xmlFSType.VolumeName = CurrentEncoding.GetString(audiSb.id); xmlFSType.VolumeSerial = string.Format("{0:X16}", audiSb.serial); information = sb.ToString(); @@ -199,7 +202,7 @@ namespace DiscImageChef.Filesystems sb.AppendFormat("Flags: 0x{0:X8}", qnxSb.flags).AppendLine(); sb.AppendFormat("Version1: 0x{0:X4}", qnxSb.version1).AppendLine(); sb.AppendFormat("Version2: 0x{0:X4}", qnxSb.version2).AppendLine(); - //sb.AppendFormat("Volume ID: \"{0}\"", Encoding.ASCII.GetString(qnxSb.volumeid)).AppendLine(); + //sb.AppendFormat("Volume ID: \"{0}\"", CurrentEncoding.GetString(qnxSb.volumeid)).AppendLine(); sb.AppendFormat("{0} bytes per block", qnxSb.blockSize).AppendLine(); sb.AppendFormat("{0} inodes free of {1}", qnxSb.freeInodes, qnxSb.numInodes).AppendLine(); sb.AppendFormat("{0} blocks ({1} bytes) free of {2} ({3} bytes)", qnxSb.freeBlocks, qnxSb.freeBlocks * qnxSb.blockSize, @@ -214,7 +217,7 @@ namespace DiscImageChef.Filesystems xmlFSType.FilesSpecified = true; xmlFSType.FreeClusters = qnxSb.freeBlocks; xmlFSType.FreeClustersSpecified = true; - //xmlFSType.VolumeName = Encoding.ASCII.GetString(qnxSb.volumeid); + //xmlFSType.VolumeName = CurrentEncoding.GetString(qnxSb.volumeid); xmlFSType.VolumeSerial = string.Format("{0:X16}", qnxSb.serial); xmlFSType.CreationDate = DateHandlers.UNIXUnsignedToDateTime(qnxSb.ctime); xmlFSType.CreationDateSpecified = true; diff --git a/DiscImageChef.Filesystems/Reiser.cs b/DiscImageChef.Filesystems/Reiser.cs index 0f9a0d0d..301c0921 100644 --- a/DiscImageChef.Filesystems/Reiser.cs +++ b/DiscImageChef.Filesystems/Reiser.cs @@ -94,12 +94,15 @@ namespace DiscImageChef.Filesystems { Name = "Reiser Filesystem Plugin"; PluginUUID = new Guid("1D8CD8B8-27E6-410F-9973-D16409225FBA"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public Reiser(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public Reiser(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Reiser Filesystem Plugin"; PluginUUID = new Guid("1D8CD8B8-27E6-410F-9973-D16409225FBA"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -178,7 +181,7 @@ namespace DiscImageChef.Filesystems if(reiserSb.version >= 2) { sb.AppendFormat("Volume UUID: {0}", reiserSb.uuid).AppendLine(); - sb.AppendFormat("Volume name: {0}", Encoding.ASCII.GetString(reiserSb.label)).AppendLine(); + sb.AppendFormat("Volume name: {0}", CurrentEncoding.GetString(reiserSb.label)).AppendLine(); } information = sb.ToString(); @@ -197,7 +200,7 @@ namespace DiscImageChef.Filesystems xmlFSType.Dirty = reiserSb.umount_state == 2; if(reiserSb.version >= 2) { - xmlFSType.VolumeName = Encoding.ASCII.GetString(reiserSb.label); + xmlFSType.VolumeName = CurrentEncoding.GetString(reiserSb.label); xmlFSType.VolumeSerial = reiserSb.uuid.ToString(); } } diff --git a/DiscImageChef.Filesystems/Reiser4.cs b/DiscImageChef.Filesystems/Reiser4.cs index a0d16e5b..8581ea43 100644 --- a/DiscImageChef.Filesystems/Reiser4.cs +++ b/DiscImageChef.Filesystems/Reiser4.cs @@ -59,12 +59,15 @@ namespace DiscImageChef.Filesystems { Name = "Reiser4 Filesystem Plugin"; PluginUUID = new Guid("301F2D00-E8D5-4F04-934E-81DFB21D15BA"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public Reiser4(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public Reiser4(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Reiser4 Filesystem Plugin"; PluginUUID = new Guid("301F2D00-E8D5-4F04-934E-81DFB21D15BA"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -128,7 +131,7 @@ namespace DiscImageChef.Filesystems sb.AppendFormat("{0} bytes per block", reiserSb.blocksize).AppendLine(); sb.AppendFormat("Volume disk format: {0}", reiserSb.diskformat).AppendLine(); sb.AppendFormat("Volume UUID: {0}", reiserSb.uuid).AppendLine(); - sb.AppendFormat("Volume name: {0}", Encoding.ASCII.GetString(reiserSb.label)).AppendLine(); + sb.AppendFormat("Volume name: {0}", CurrentEncoding.GetString(reiserSb.label)).AppendLine(); information = sb.ToString(); @@ -136,7 +139,7 @@ namespace DiscImageChef.Filesystems xmlFSType.Type = "Reiser 4 filesystem"; xmlFSType.ClusterSize = reiserSb.blocksize; xmlFSType.Clusters = (long)(((partitionEnd - partitionStart) * imagePlugin.GetSectorSize()) / reiserSb.blocksize); - xmlFSType.VolumeName = Encoding.ASCII.GetString(reiserSb.label); + xmlFSType.VolumeName = CurrentEncoding.GetString(reiserSb.label); xmlFSType.VolumeSerial = reiserSb.uuid.ToString(); } diff --git a/DiscImageChef.Filesystems/SFS.cs b/DiscImageChef.Filesystems/SFS.cs index 4de326b3..547cd034 100644 --- a/DiscImageChef.Filesystems/SFS.cs +++ b/DiscImageChef.Filesystems/SFS.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "SmartFileSystem"; PluginUUID = new Guid("26550C19-3671-4A2D-BC2F-F20CEB7F48DC"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } - public SFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public SFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "SmartFileSystem"; PluginUUID = new Guid("26550C19-3671-4A2D-BC2F-F20CEB7F48DC"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-1"); } [Flags] diff --git a/DiscImageChef.Filesystems/SolarFS.cs b/DiscImageChef.Filesystems/SolarFS.cs index dee711d2..5625c616 100644 --- a/DiscImageChef.Filesystems/SolarFS.cs +++ b/DiscImageChef.Filesystems/SolarFS.cs @@ -44,12 +44,15 @@ namespace DiscImageChef.Filesystems { Name = "Solar_OS filesystem"; PluginUUID = new Guid("EA3101C1-E777-4B4F-B5A3-8C57F50F6E65"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public SolarFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public SolarFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Solar_OS filesystem"; PluginUUID = new Guid("EA3101C1-E777-4B4F-B5A3-8C57F50F6E65"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -96,10 +99,10 @@ namespace DiscImageChef.Filesystems BPB.signature = bpb_sector[0x25]; bpb_strings = new byte[8]; Array.Copy(bpb_sector, 0x2A, bpb_strings, 0, 11); - BPB.vol_name = StringHandlers.CToString(bpb_strings); + BPB.vol_name = StringHandlers.CToString(bpb_strings, CurrentEncoding); bpb_strings = new byte[8]; Array.Copy(bpb_sector, 0x35, bpb_strings, 0, 8); - BPB.fs_type = StringHandlers.CToString(bpb_strings); + BPB.fs_type = StringHandlers.CToString(bpb_strings, CurrentEncoding); BPB.x86_jump = new byte[3]; Array.Copy(bpb_sector, 0x00, BPB.x86_jump, 0, 3); diff --git a/DiscImageChef.Filesystems/Squash.cs b/DiscImageChef.Filesystems/Squash.cs index 335afb68..4de15090 100644 --- a/DiscImageChef.Filesystems/Squash.cs +++ b/DiscImageChef.Filesystems/Squash.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "Squash filesystem"; PluginUUID = new Guid("F8F6E46F-7A2A-48E3-9C0A-46AF4DC29E09"); + CurrentEncoding = Encoding.UTF8; } - public Squash(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public Squash(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Squash filesystem"; PluginUUID = new Guid("F8F6E46F-7A2A-48E3-9C0A-46AF4DC29E09"); + if(encoding == null) + CurrentEncoding = Encoding.UTF8; } enum SquashCompression : ushort diff --git a/DiscImageChef.Filesystems/SysV.cs b/DiscImageChef.Filesystems/SysV.cs index 50c94f67..5a337e1a 100644 --- a/DiscImageChef.Filesystems/SysV.cs +++ b/DiscImageChef.Filesystems/SysV.cs @@ -58,12 +58,15 @@ namespace DiscImageChef.Filesystems { Name = "UNIX System V filesystem"; PluginUUID = new Guid("9B8D016A-8561-400E-A12A-A198283C211D"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public SysVfs(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public SysVfs(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "UNIX System V filesystem"; PluginUUID = new Guid("9B8D016A-8561-400E-A12A-A198283C211D"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -131,9 +134,9 @@ namespace DiscImageChef.Filesystems byte[] coherent_string = new byte[6]; Array.Copy(sb_sector, 0x1E8, coherent_string, 0, 6); // Coherent UNIX s_fname location - s_fname = StringHandlers.CToString(coherent_string); + s_fname = StringHandlers.CToString(coherent_string, CurrentEncoding); Array.Copy(sb_sector, 0x1EE, coherent_string, 0, 6); // Coherent UNIX s_fpack location - s_fpack = StringHandlers.CToString(coherent_string); + s_fpack = StringHandlers.CToString(coherent_string, CurrentEncoding); if(s_fname == COH_FNAME || s_fpack == COH_FPACK) return true; @@ -243,9 +246,9 @@ namespace DiscImageChef.Filesystems byte[] coherent_string = new byte[6]; Array.Copy(sb_sector, 0x1E8, coherent_string, 0, 6); // Coherent UNIX s_fname location - s_fname = StringHandlers.CToString(coherent_string); + s_fname = StringHandlers.CToString(coherent_string, CurrentEncoding); Array.Copy(sb_sector, 0x1EE, coherent_string, 0, 6); // Coherent UNIX s_fpack location - s_fpack = StringHandlers.CToString(coherent_string); + s_fpack = StringHandlers.CToString(coherent_string, CurrentEncoding); if(s_fname == COH_FNAME || s_fpack == COH_FPACK) { @@ -312,9 +315,9 @@ namespace DiscImageChef.Filesystems xnx_sb.s_dinfo0 = BigEndianBitConverter.ToUInt16(sb_sector, 0x1AC); xnx_sb.s_dinfo1 = BigEndianBitConverter.ToUInt16(sb_sector, 0x1AE); Array.Copy(sb_sector, 0x1B0, xenix_strings, 0, 6); - xnx_sb.s_fname = StringHandlers.CToString(xenix_strings); + xnx_sb.s_fname = StringHandlers.CToString(xenix_strings, CurrentEncoding); Array.Copy(sb_sector, 0x1B6, xenix_strings, 0, 6); - xnx_sb.s_fpack = StringHandlers.CToString(xenix_strings); + xnx_sb.s_fpack = StringHandlers.CToString(xenix_strings, CurrentEncoding); xnx_sb.s_clean = sb_sector[0x1BC]; xnx_sb.s_magic = BigEndianBitConverter.ToUInt32(sb_sector, 0x1F0); xnx_sb.s_type = BigEndianBitConverter.ToUInt32(sb_sector, 0x1F4); @@ -337,9 +340,9 @@ namespace DiscImageChef.Filesystems xnx_sb.s_dinfo0 = BigEndianBitConverter.ToUInt16(sb_sector, 0x274); xnx_sb.s_dinfo1 = BigEndianBitConverter.ToUInt16(sb_sector, 0x276); Array.Copy(sb_sector, 0x278, xenix_strings, 0, 6); - xnx_sb.s_fname = StringHandlers.CToString(xenix_strings); + xnx_sb.s_fname = StringHandlers.CToString(xenix_strings, CurrentEncoding); Array.Copy(sb_sector, 0x27E, xenix_strings, 0, 6); - xnx_sb.s_fpack = StringHandlers.CToString(xenix_strings); + xnx_sb.s_fpack = StringHandlers.CToString(xenix_strings, CurrentEncoding); xnx_sb.s_clean = sb_sector[0x284]; xnx_sb.s_magic = BigEndianBitConverter.ToUInt32(sb_sector, 0x3F8); xnx_sb.s_type = BigEndianBitConverter.ToUInt32(sb_sector, 0x3FC); @@ -450,9 +453,9 @@ namespace DiscImageChef.Filesystems sysv_sb.s_tfree = BigEndianBitConverter.ToUInt32(sb_sector, 0x1B0); sysv_sb.s_tinode = BigEndianBitConverter.ToUInt16(sb_sector, 0x1B4); Array.Copy(sb_sector, 0x1B8, sysv_strings, 0, 6); - sysv_sb.s_fname = StringHandlers.CToString(sysv_strings); + sysv_sb.s_fname = StringHandlers.CToString(sysv_strings, CurrentEncoding); Array.Copy(sb_sector, 0x1BE, sysv_strings, 0, 6); - sysv_sb.s_fpack = StringHandlers.CToString(sysv_strings); + sysv_sb.s_fpack = StringHandlers.CToString(sysv_strings, CurrentEncoding); } else { @@ -471,9 +474,9 @@ namespace DiscImageChef.Filesystems sysv_sb.s_tfree = BigEndianBitConverter.ToUInt32(sb_sector, 0x1AA); sysv_sb.s_tinode = BigEndianBitConverter.ToUInt16(sb_sector, 0x1AE); Array.Copy(sb_sector, 0x1B0, sysv_strings, 0, 6); - sysv_sb.s_fname = StringHandlers.CToString(sysv_strings); + sysv_sb.s_fname = StringHandlers.CToString(sysv_strings, CurrentEncoding); Array.Copy(sb_sector, 0x1B6, sysv_strings, 0, 6); - sysv_sb.s_fpack = StringHandlers.CToString(sysv_strings); + sysv_sb.s_fpack = StringHandlers.CToString(sysv_strings, CurrentEncoding); } uint bs = 512; @@ -571,9 +574,9 @@ namespace DiscImageChef.Filesystems coh_sb.s_int_m = BigEndianBitConverter.ToUInt16(sb_sector, 0x1E4); coh_sb.s_int_n = BigEndianBitConverter.ToUInt16(sb_sector, 0x1E6); Array.Copy(sb_sector, 0x1E8, coh_strings, 0, 6); - coh_sb.s_fname = StringHandlers.CToString(coh_strings); + coh_sb.s_fname = StringHandlers.CToString(coh_strings, CurrentEncoding); Array.Copy(sb_sector, 0x1EE, coh_strings, 0, 6); - coh_sb.s_fpack = StringHandlers.CToString(coh_strings); + coh_sb.s_fpack = StringHandlers.CToString(coh_strings, CurrentEncoding); xmlFSType.Type = "Coherent fs"; xmlFSType.ClusterSize = 512; @@ -626,9 +629,9 @@ namespace DiscImageChef.Filesystems v7_sb.s_int_m = BigEndianBitConverter.ToUInt16(sb_sector, 0x1A8); v7_sb.s_int_n = BigEndianBitConverter.ToUInt16(sb_sector, 0x1AA); Array.Copy(sb_sector, 0x1AC, sys7_strings, 0, 6); - v7_sb.s_fname = StringHandlers.CToString(sys7_strings); + v7_sb.s_fname = StringHandlers.CToString(sys7_strings, CurrentEncoding); Array.Copy(sb_sector, 0x1B2, sys7_strings, 0, 6); - v7_sb.s_fpack = StringHandlers.CToString(sys7_strings); + v7_sb.s_fpack = StringHandlers.CToString(sys7_strings, CurrentEncoding); xmlFSType.Type = "UNIX 7th Edition fs"; xmlFSType.ClusterSize = 512; diff --git a/DiscImageChef.Filesystems/UCSDPascal/Dir.cs b/DiscImageChef.Filesystems/UCSDPascal/Dir.cs index ae8f9853..c6db8129 100644 --- a/DiscImageChef.Filesystems/UCSDPascal/Dir.cs +++ b/DiscImageChef.Filesystems/UCSDPascal/Dir.cs @@ -48,7 +48,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal contents = new List(); foreach(PascalFileEntry ent in fileEntries) - contents.Add(StringHandlers.PascalToString(ent.filename)); + contents.Add(StringHandlers.PascalToString(ent.filename, CurrentEncoding)); if(debug) { diff --git a/DiscImageChef.Filesystems/UCSDPascal/File.cs b/DiscImageChef.Filesystems/UCSDPascal/File.cs index a5ea0600..15c03d12 100644 --- a/DiscImageChef.Filesystems/UCSDPascal/File.cs +++ b/DiscImageChef.Filesystems/UCSDPascal/File.cs @@ -185,7 +185,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal foreach(PascalFileEntry ent in fileEntries) { - if(string.Compare(path, StringHandlers.PascalToString(ent.filename), StringComparison.InvariantCultureIgnoreCase) == 0) + if(string.Compare(path, StringHandlers.PascalToString(ent.filename, CurrentEncoding), StringComparison.InvariantCultureIgnoreCase) == 0) { entry = ent; return Errno.NoError; diff --git a/DiscImageChef.Filesystems/UCSDPascal/Info.cs b/DiscImageChef.Filesystems/UCSDPascal/Info.cs index d1372b9c..81b32f56 100644 --- a/DiscImageChef.Filesystems/UCSDPascal/Info.cs +++ b/DiscImageChef.Filesystems/UCSDPascal/Info.cs @@ -139,7 +139,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal return; sbInformation.AppendFormat("Volume record spans from block {0} to block {1}", volEntry.firstBlock, volEntry.lastBlock).AppendLine(); - sbInformation.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(volEntry.volumeName)).AppendLine(); + sbInformation.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(volEntry.volumeName, CurrentEncoding)).AppendLine(); sbInformation.AppendFormat("Volume has {0} blocks", volEntry.blocks).AppendLine(); sbInformation.AppendFormat("Volume has {0} files", volEntry.files).AppendLine(); sbInformation.AppendFormat("Volume last booted at {0}", DateHandlers.UCSDPascalToDateTime(volEntry.lastBoot)).AppendLine(); @@ -153,7 +153,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal xmlFSType.Files = volEntry.files; xmlFSType.FilesSpecified = true; xmlFSType.Type = "UCSD Pascal"; - xmlFSType.VolumeName = StringHandlers.PascalToString(volEntry.volumeName); + xmlFSType.VolumeName = StringHandlers.PascalToString(volEntry.volumeName, CurrentEncoding); return; } diff --git a/DiscImageChef.Filesystems/UCSDPascal/Super.cs b/DiscImageChef.Filesystems/UCSDPascal/Super.cs index 76ce9778..455d075a 100644 --- a/DiscImageChef.Filesystems/UCSDPascal/Super.cs +++ b/DiscImageChef.Filesystems/UCSDPascal/Super.cs @@ -102,7 +102,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal xmlFSType.Files = mountedVolEntry.files; xmlFSType.FilesSpecified = true; xmlFSType.Type = "UCSD Pascal"; - xmlFSType.VolumeName = StringHandlers.PascalToString(mountedVolEntry.volumeName); + xmlFSType.VolumeName = StringHandlers.PascalToString(mountedVolEntry.volumeName, CurrentEncoding); mounted = true; diff --git a/DiscImageChef.Filesystems/UCSDPascal/UCSDPascal.cs b/DiscImageChef.Filesystems/UCSDPascal/UCSDPascal.cs index 0fac9e83..847a1302 100644 --- a/DiscImageChef.Filesystems/UCSDPascal/UCSDPascal.cs +++ b/DiscImageChef.Filesystems/UCSDPascal/UCSDPascal.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; +using System.Text; using DiscImageChef.ImagePlugins; namespace DiscImageChef.Filesystems.UCSDPascal @@ -52,13 +53,16 @@ namespace DiscImageChef.Filesystems.UCSDPascal { Name = "U.C.S.D. Pascal filesystem"; PluginUUID = new Guid("B0AC2CB5-72AA-473A-9200-270B5A2C2D53"); + CurrentEncoding = new Claunia.Encoding.LisaRoman(); } - public PascalPlugin(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public PascalPlugin(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { device = imagePlugin; Name = "U.C.S.D. Pascal filesystem"; PluginUUID = new Guid("B0AC2CB5-72AA-473A-9200-270B5A2C2D53"); + if(encoding == null) // TODO: Until Apple ][ encoding is implemented + CurrentEncoding = new Claunia.Encoding.LisaRoman(); } public override Errno ListXAttr(string path, ref List xattrs) diff --git a/DiscImageChef.Filesystems/UDF.cs b/DiscImageChef.Filesystems/UDF.cs index 142667ac..1b41378b 100644 --- a/DiscImageChef.Filesystems/UDF.cs +++ b/DiscImageChef.Filesystems/UDF.cs @@ -47,12 +47,15 @@ namespace DiscImageChef.Filesystems { Name = "Universal Disk Format"; PluginUUID = new Guid("83976FEC-A91B-464B-9293-56C719461BAB"); + CurrentEncoding = Encoding.UTF8; } - public UDF(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public UDF(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Universal Disk Format"; PluginUUID = new Guid("83976FEC-A91B-464B-9293-56C719461BAB"); + // UDF is always UTF-8 + CurrentEncoding = Encoding.UTF8; } readonly byte[] UDF_Magic = { 0x2A, 0x4F, 0x53, 0x54, 0x41, 0x20, 0x55, 0x44, 0x46, 0x20, 0x43, 0x6F, 0x6D, 0x70, 0x6C, 0x69, 0x61, 0x6E, 0x74, 0x00, 0x00, 0x00, 0x00 }; @@ -403,8 +406,8 @@ namespace DiscImageChef.Filesystems sbInformation.AppendFormat("Volume was las written in {0}", ECMAToDateTime(lvid.recordingDateTime)).AppendLine(); sbInformation.AppendFormat("Volume contains {0} partitions", lvid.numberOfPartitions).AppendLine(); sbInformation.AppendFormat("Volume contains {0} files and {1} directories", lvidiu.files, lvidiu.directories).AppendLine(); - sbInformation.AppendFormat("Volume conforms to {0}", Encoding.UTF8.GetString(lvd.domainIdentifier.identifier).TrimEnd(new char[] { '\u0000' })).AppendLine(); - sbInformation.AppendFormat("Volume was last written by: {0}", Encoding.UTF8.GetString(pvd.implementationIdentifier.identifier).TrimEnd(new char[]{ '\u0000' })).AppendLine(); + sbInformation.AppendFormat("Volume conforms to {0}", CurrentEncoding.GetString(lvd.domainIdentifier.identifier).TrimEnd(new char[] { '\u0000' })).AppendLine(); + sbInformation.AppendFormat("Volume was last written by: {0}", CurrentEncoding.GetString(pvd.implementationIdentifier.identifier).TrimEnd(new char[]{ '\u0000' })).AppendLine(); sbInformation.AppendFormat("Volume requires UDF version {0}.{1:D2} to be read", Convert.ToInt32(string.Format("{0}", (lvidiu.minimumReadUDF & 0xFF00) >> 8), 10), Convert.ToInt32(string.Format("{0}", lvidiu.minimumReadUDF & 0xFF), 10)).AppendLine(); sbInformation.AppendFormat("Volume requires UDF version {0}.{1:D2} to be written to", Convert.ToInt32(string.Format("{0}", (lvidiu.minimumWriteUDF & 0xFF00) >> 8), 10), @@ -415,7 +418,7 @@ namespace DiscImageChef.Filesystems xmlFSType = new Schemas.FileSystemType(); xmlFSType.Type = string.Format("UDF v{0}.{1:D2}", Convert.ToInt32(string.Format("{0}", (lvidiu.minimumReadUDF & 0xFF00) >> 8), 10), Convert.ToInt32(string.Format("{0}", lvidiu.minimumReadUDF & 0xFF), 10)); - xmlFSType.ApplicationIdentifier = Encoding.UTF8.GetString(pvd.implementationIdentifier.identifier).TrimEnd(new char[] { '\u0000' }); + xmlFSType.ApplicationIdentifier = CurrentEncoding.GetString(pvd.implementationIdentifier.identifier).TrimEnd(new char[] { '\u0000' }); xmlFSType.ClusterSize = (int)lvd.logicalBlockSize; xmlFSType.Clusters = (long)(((partitionEnd - partitionStart + 1) * imagePlugin.ImageInfo.sectorSize) / (ulong)xmlFSType.ClusterSize); xmlFSType.ModificationDate = ECMAToDateTime(lvid.recordingDateTime); diff --git a/DiscImageChef.Filesystems/UNIXBFS.cs b/DiscImageChef.Filesystems/UNIXBFS.cs index 8760c453..45cbf4b9 100644 --- a/DiscImageChef.Filesystems/UNIXBFS.cs +++ b/DiscImageChef.Filesystems/UNIXBFS.cs @@ -46,12 +46,15 @@ namespace DiscImageChef.Filesystems { Name = "UNIX Boot filesystem"; PluginUUID = new Guid("1E6E0DA6-F7E4-494C-80C6-CB5929E96155"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public BFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public BFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "UNIX Boot filesystem"; PluginUUID = new Guid("1E6E0DA6-F7E4-494C-80C6-CB5929E96155"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -84,9 +87,9 @@ namespace DiscImageChef.Filesystems bfs_sb.s_bfrom = BitConverter.ToInt32(bfs_sb_sector, 0x14); bfs_sb.s_bto = BitConverter.ToInt32(bfs_sb_sector, 0x18); Array.Copy(bfs_sb_sector, 0x1C, sb_strings, 0, 6); - bfs_sb.s_fsname = StringHandlers.CToString(sb_strings); + bfs_sb.s_fsname = StringHandlers.CToString(sb_strings, CurrentEncoding); Array.Copy(bfs_sb_sector, 0x22, sb_strings, 0, 6); - bfs_sb.s_volume = StringHandlers.CToString(sb_strings); + bfs_sb.s_volume = StringHandlers.CToString(sb_strings, CurrentEncoding); DicConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_magic: 0x{0:X8}", bfs_sb.s_magic); DicConsole.DebugWriteLine("BFS plugin", "bfs_sb.s_start: 0x{0:X8}", bfs_sb.s_start); diff --git a/DiscImageChef.Filesystems/VMfs.cs b/DiscImageChef.Filesystems/VMfs.cs index de2bb226..bb1f3efd 100644 --- a/DiscImageChef.Filesystems/VMfs.cs +++ b/DiscImageChef.Filesystems/VMfs.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "VMware filesystem"; PluginUUID = new Guid("EE52BDB8-B49C-4122-A3DA-AD21CBE79843"); + CurrentEncoding = Encoding.UTF8; } - public VMfs(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public VMfs(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "VMware filesystem"; PluginUUID = new Guid("EE52BDB8-B49C-4122-A3DA-AD21CBE79843"); + if(encoding == null) + CurrentEncoding = Encoding.UTF8; } [Flags] @@ -124,7 +127,7 @@ namespace DiscImageChef.Filesystems uint mtimeNanoSecs = (uint)(volInfo.mtime % 1000000); sbInformation.AppendFormat("Volume version {0}", volInfo.version).AppendLine(); - sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(volInfo.name)).AppendLine(); + sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(volInfo.name, CurrentEncoding)).AppendLine(); sbInformation.AppendFormat("Volume size {0} bytes", volInfo.size * 256).AppendLine(); sbInformation.AppendFormat("Volume UUID {0}", volInfo.uuid).AppendLine(); sbInformation.AppendFormat("Volume created on {0}", DateHandlers.UNIXUnsignedToDateTime(ctimeSecs, ctimeNanoSecs)).AppendLine(); diff --git a/DiscImageChef.Filesystems/VxFS.cs b/DiscImageChef.Filesystems/VxFS.cs index b5a537af..745b357f 100644 --- a/DiscImageChef.Filesystems/VxFS.cs +++ b/DiscImageChef.Filesystems/VxFS.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "Veritas filesystem"; PluginUUID = new Guid("EC372605-7687-453C-8BEA-7E0DFF79CB03"); + CurrentEncoding = Encoding.UTF8; } - public VxFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public VxFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Veritas filesystem"; PluginUUID = new Guid("EC372605-7687-453C-8BEA-7E0DFF79CB03"); + if(encoding == null) + CurrentEncoding = Encoding.UTF8; } [StructLayout(LayoutKind.Sequential, Pack = 1)] @@ -233,7 +236,7 @@ namespace DiscImageChef.Filesystems sbInformation.AppendLine("Veritas file system"); sbInformation.AppendFormat("Volume version {0}", vxSb.vs_version).AppendLine(); - sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(vxSb.vs_fname)).AppendLine(); + sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(vxSb.vs_fname, CurrentEncoding)).AppendLine(); sbInformation.AppendFormat("Volume has {0} blocks of {1} bytes each", vxSb.vs_bsize, vxSb.vs_size).AppendLine(); sbInformation.AppendFormat("Volume has {0} inodes per block", vxSb.vs_inopb).AppendLine(); sbInformation.AppendFormat("Volume has {0} free inodes", vxSb.vs_ifree).AppendLine(); diff --git a/DiscImageChef.Filesystems/XFS.cs b/DiscImageChef.Filesystems/XFS.cs index fb987f74..23088378 100644 --- a/DiscImageChef.Filesystems/XFS.cs +++ b/DiscImageChef.Filesystems/XFS.cs @@ -107,12 +107,15 @@ namespace DiscImageChef.Filesystems { Name = "XFS Filesystem Plugin"; PluginUUID = new Guid("1D8CD8B8-27E6-410F-9973-D16409225FBA"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public XFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public XFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "XFS Filesystem Plugin"; PluginUUID = new Guid("1D8CD8B8-27E6-410F-9973-D16409225FBA"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -169,7 +172,7 @@ namespace DiscImageChef.Filesystems sb.AppendFormat("{0} inodes in volume, {1} free", xfsSb.icount, xfsSb.ifree).AppendLine(); if(xfsSb.inprogress > 0) sb.AppendLine("fsck in progress"); - sb.AppendFormat("Volume name: {0}", Encoding.ASCII.GetString(xfsSb.fname)).AppendLine(); + sb.AppendFormat("Volume name: {0}", CurrentEncoding.GetString(xfsSb.fname)).AppendLine(); sb.AppendFormat("Volume UUID: {0}", xfsSb.uuid).AppendLine(); information = sb.ToString(); @@ -183,7 +186,7 @@ namespace DiscImageChef.Filesystems xmlFSType.Files = (long)(xfsSb.icount - xfsSb.ifree); xmlFSType.FilesSpecified = true; xmlFSType.Dirty |= xfsSb.inprogress > 0; - xmlFSType.VolumeName = Encoding.ASCII.GetString(xfsSb.fname); + xmlFSType.VolumeName = CurrentEncoding.GetString(xfsSb.fname); xmlFSType.VolumeSerial = xfsSb.uuid.ToString(); } diff --git a/DiscImageChef.Filesystems/ZFS.cs b/DiscImageChef.Filesystems/ZFS.cs index dd8ac2d6..1666757f 100644 --- a/DiscImageChef.Filesystems/ZFS.cs +++ b/DiscImageChef.Filesystems/ZFS.cs @@ -229,12 +229,15 @@ namespace DiscImageChef.Filesystems { Name = "ZFS Filesystem Plugin"; PluginUUID = new Guid("0750014F-A714-4692-A369-E23F6EC3659C"); + CurrentEncoding = Encoding.UTF8; } - public ZFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public ZFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "ZFS Filesystem Plugin"; PluginUUID = new Guid("0750014F-A714-4692-A369-E23F6EC3659C"); + // ZFS is always UTF-8 + CurrentEncoding = Encoding.UTF8; } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filesystems/exFAT.cs b/DiscImageChef.Filesystems/exFAT.cs index b60ccd3e..beb7c480 100644 --- a/DiscImageChef.Filesystems/exFAT.cs +++ b/DiscImageChef.Filesystems/exFAT.cs @@ -46,12 +46,15 @@ namespace DiscImageChef.Filesystems { Name = "Microsoft Extended File Allocation Table"; PluginUUID = new Guid("8271D088-1533-4CB3-AC28-D802B68BB95C"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public exFAT(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public exFAT(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Microsoft Extended File Allocation Table"; PluginUUID = new Guid("8271D088-1533-4CB3-AC28-D802B68BB95C"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filesystems/ext2FS.cs b/DiscImageChef.Filesystems/ext2FS.cs index 2da1e222..3f6f9f8a 100644 --- a/DiscImageChef.Filesystems/ext2FS.cs +++ b/DiscImageChef.Filesystems/ext2FS.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "Linux extended Filesystem 2, 3 and 4"; PluginUUID = new Guid("6AA91B88-150B-4A7B-AD56-F84FB2DF4184"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public ext2FS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public ext2FS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Linux extended Filesystem 2, 3 and 4"; PluginUUID = new Guid("6AA91B88-150B-4A7B-AD56-F84FB2DF4184"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) @@ -149,10 +152,10 @@ namespace DiscImageChef.Filesystems // End of volume UUID forstrings = new byte[16]; Array.Copy(sb_sector, 0x078, forstrings, 0, 16); - supblk.volume_name = StringHandlers.CToString(forstrings); + supblk.volume_name = StringHandlers.CToString(forstrings, CurrentEncoding); forstrings = new byte[64]; Array.Copy(sb_sector, 0x088, forstrings, 0, 64); - supblk.last_mount_dir = StringHandlers.CToString(forstrings); + supblk.last_mount_dir = StringHandlers.CToString(forstrings, CurrentEncoding); supblk.algo_usage_bmp = BitConverter.ToUInt32(sb_sector, 0x0C8); supblk.prealloc_blks = sb_sector[0x0CC]; supblk.prealloc_dir_blks = sb_sector[0x0CD]; @@ -212,7 +215,7 @@ namespace DiscImageChef.Filesystems supblk.first_error_block = BitConverter.ToUInt64(sb_sector, 0x19C); forstrings = new byte[32]; Array.Copy(sb_sector, 0x1A0, forstrings, 0, 32); - supblk.first_error_func = StringHandlers.CToString(forstrings); + supblk.first_error_func = StringHandlers.CToString(forstrings, CurrentEncoding); supblk.first_error_line = BitConverter.ToUInt32(sb_sector, 0x1B0); supblk.last_error_t = BitConverter.ToUInt32(sb_sector, 0x1B4); supblk.last_error_inode = BitConverter.ToUInt32(sb_sector, 0x1B8); @@ -220,10 +223,10 @@ namespace DiscImageChef.Filesystems supblk.last_error_block = BitConverter.ToUInt64(sb_sector, 0x1C0); forstrings = new byte[32]; Array.Copy(sb_sector, 0x1C8, forstrings, 0, 32); - supblk.last_error_func = StringHandlers.CToString(forstrings); + supblk.last_error_func = StringHandlers.CToString(forstrings, CurrentEncoding); forstrings = new byte[64]; Array.Copy(sb_sector, 0x1D8, forstrings, 0, 64); - supblk.mount_options = StringHandlers.CToString(forstrings); + supblk.mount_options = StringHandlers.CToString(forstrings, CurrentEncoding); xmlFSType = new Schemas.FileSystemType(); diff --git a/DiscImageChef.Filesystems/extFS.cs b/DiscImageChef.Filesystems/extFS.cs index 80249238..02c3f3c1 100644 --- a/DiscImageChef.Filesystems/extFS.cs +++ b/DiscImageChef.Filesystems/extFS.cs @@ -43,12 +43,15 @@ namespace DiscImageChef.Filesystems { Name = "Linux extended Filesystem"; PluginUUID = new Guid("076CB3A2-08C2-4D69-BC8A-FCAA2E502BE2"); + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } - public extFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) + public extFS(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, Encoding encoding) { Name = "Linux extended Filesystem"; PluginUUID = new Guid("076CB3A2-08C2-4D69-BC8A-FCAA2E502BE2"); + if(encoding == null) + CurrentEncoding = Encoding.GetEncoding("iso-8859-15"); } public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd) diff --git a/DiscImageChef.Filters/MacBinary.cs b/DiscImageChef.Filters/MacBinary.cs index 5285dfc0..787aff58 100644 --- a/DiscImageChef.Filters/MacBinary.cs +++ b/DiscImageChef.Filters/MacBinary.cs @@ -33,6 +33,7 @@ using System; using System.IO; using System.Runtime.InteropServices; +using System.Text; namespace DiscImageChef.Filters { @@ -336,7 +337,7 @@ namespace DiscImageChef.Filters blocks++; rsrcForkOff = blocks * 128; - filename = StringHandlers.PascalToString(header.filename); + filename = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh")); creationTime = DateHandlers.MacToDateTime(header.creationTime); lastWriteTime = DateHandlers.MacToDateTime(header.modificationTime); @@ -364,7 +365,7 @@ namespace DiscImageChef.Filters blocks++; rsrcForkOff = blocks * 128; - filename = StringHandlers.PascalToString(header.filename); + filename = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh")); creationTime = DateHandlers.MacToDateTime(header.creationTime); lastWriteTime = DateHandlers.MacToDateTime(header.modificationTime); @@ -393,7 +394,7 @@ namespace DiscImageChef.Filters blocks++; rsrcForkOff = blocks * 128; - filename = StringHandlers.PascalToString(header.filename); + filename = StringHandlers.PascalToString(header.filename, Encoding.GetEncoding("macintosh")); creationTime = DateHandlers.MacToDateTime(header.creationTime); lastWriteTime = DateHandlers.MacToDateTime(header.modificationTime); diff --git a/DiscImageChef.Filters/PCExchange.cs b/DiscImageChef.Filters/PCExchange.cs index 38fe8895..1967b208 100644 --- a/DiscImageChef.Filters/PCExchange.cs +++ b/DiscImageChef.Filters/PCExchange.cs @@ -221,7 +221,8 @@ namespace DiscImageChef.Filters byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)]; finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry)); datEntry = BigEndianMarshal.ByteArrayToStructureBigEndian(datEntry_b); - string macName = StringHandlers.PascalToString(datEntry.macName); + // TODO: Add support for encoding on filters + string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh")); byte[] tmpDosName_b = new byte[8]; byte[] tmpDosExt_b = new byte[3]; Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8); @@ -274,7 +275,7 @@ namespace DiscImageChef.Filters byte[] datEntry_b = new byte[Marshal.SizeOf(datEntry)]; finderDatStream.Read(datEntry_b, 0, Marshal.SizeOf(datEntry)); datEntry = BigEndianMarshal.ByteArrayToStructureBigEndian(datEntry_b); - string macName = StringHandlers.PascalToString(datEntry.macName); + string macName = StringHandlers.PascalToString(datEntry.macName, Encoding.GetEncoding("macintosh")); byte[] tmpDosName_b = new byte[8]; byte[] tmpDosExt_b = new byte[3]; Array.Copy(datEntry.dosName, 0, tmpDosName_b, 0, 8); diff --git a/DiscImageChef.Helpers/DateHandlers.cs b/DiscImageChef.Helpers/DateHandlers.cs index ce27ce59..8d90eda6 100644 --- a/DiscImageChef.Helpers/DateHandlers.cs +++ b/DiscImageChef.Helpers/DateHandlers.cs @@ -32,6 +32,7 @@ using System; using DiscImageChef.Console; +using System.Text; namespace DiscImageChef { @@ -90,52 +91,52 @@ namespace DiscImageChef fourcharvalue[1] = VDDateTime[1]; fourcharvalue[2] = VDDateTime[2]; fourcharvalue[3] = VDDateTime[3]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "year = \"{0}\"", StringHandlers.CToString(fourcharvalue)); - if(!int.TryParse(StringHandlers.CToString(fourcharvalue), out year)) + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "year = \"{0}\"", StringHandlers.CToString(fourcharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(fourcharvalue, Encoding.ASCII), out year)) year = 0; - // year = Convert.ToInt32(StringHandlers.CToString(fourcharvalue)); + // year = Convert.ToInt32(StringHandlers.CToString(fourcharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[4]; twocharvalue[1] = VDDateTime[5]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "month = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue), out month)) + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "month = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out month)) month = 0; - // month = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); + // month = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[6]; twocharvalue[1] = VDDateTime[7]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "day = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue), out day)) + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "day = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out day)) day = 0; - // day = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); + // day = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[8]; twocharvalue[1] = VDDateTime[9]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hour = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue), out hour)) + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hour = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out hour)) hour = 0; - // hour = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); + // hour = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[10]; twocharvalue[1] = VDDateTime[11]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "minute = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue), out minute)) + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "minute = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out minute)) minute = 0; - // minute = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); + // minute = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[12]; twocharvalue[1] = VDDateTime[13]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "second = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue), out second)) + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "second = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out second)) second = 0; - // second = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); + // second = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); twocharvalue[0] = VDDateTime[14]; twocharvalue[1] = VDDateTime[15]; - DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hundredths = \"{0}\"", StringHandlers.CToString(twocharvalue)); - if(!int.TryParse(StringHandlers.CToString(twocharvalue), out hundredths)) + DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "hundredths = \"{0}\"", StringHandlers.CToString(twocharvalue, Encoding.ASCII)); + if(!int.TryParse(StringHandlers.CToString(twocharvalue, Encoding.ASCII), out hundredths)) hundredths = 0; - // hundredths = Convert.ToInt32(StringHandlers.CToString(twocharvalue)); + // hundredths = Convert.ToInt32(StringHandlers.CToString(twocharvalue, Encoding.ASCII)); DicConsole.DebugWriteLine("ISO9600ToDateTime handler", "decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);", year, month, day, hour, minute, second, hundredths * 10); DateTime decodedDT = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Unspecified); diff --git a/DiscImageChef.Helpers/StringHandlers.cs b/DiscImageChef.Helpers/StringHandlers.cs index 70033b45..e0a8c18e 100644 --- a/DiscImageChef.Helpers/StringHandlers.cs +++ b/DiscImageChef.Helpers/StringHandlers.cs @@ -76,6 +76,17 @@ namespace DiscImageChef /// The corresponding C# string /// A length-prefixed (aka Pascal string) ASCII byte array public static string PascalToString(byte[] PascalString) + { + return PascalToString(PascalString, Encoding.ASCII); + } + + /// + /// Converts a length-prefixed (aka Pascal string) ASCII byte array to a C# string + /// + /// The corresponding C# string + /// A length-prefixed (aka Pascal string) ASCII byte array + /// Encoding. + public static string PascalToString(byte[] PascalString, Encoding encoding) { if(PascalString == null) return null; @@ -86,7 +97,7 @@ namespace DiscImageChef for(int i = 1; i < length + 1; i++) { - sb.Append(Encoding.ASCII.GetString(PascalString, i, 1)); + sb.Append(encoding.GetString(PascalString, i, 1)); } return sb.ToString(); @@ -98,6 +109,17 @@ namespace DiscImageChef /// The corresponding C# string /// A space (' ', 0x20, ASCII SPACE) padded ASCII byte array public static string SpacePaddedToString(byte[] SpacePaddedString) + { + return SpacePaddedToString(SpacePaddedString, Encoding.ASCII); + } + + /// + /// Converts a space (' ', 0x20, ASCII SPACE) padded ASCII byte array to a C# string + /// + /// The corresponding C# string + /// A space (' ', 0x20, ASCII SPACE) padded ASCII byte array + /// Encoding. + public static string SpacePaddedToString(byte[] SpacePaddedString, Encoding encoding) { if(SpacePaddedString == null) return null; @@ -116,7 +138,7 @@ namespace DiscImageChef } } - return length == 0 ? "" : Encoding.ASCII.GetString(SpacePaddedString, 0, length); + return length == 0 ? "" : encoding.GetString(SpacePaddedString, 0, length); } /// diff --git a/DiscImageChef.Partitions/AppleMap.cs b/DiscImageChef.Partitions/AppleMap.cs index abbcddbe..122f65c7 100644 --- a/DiscImageChef.Partitions/AppleMap.cs +++ b/DiscImageChef.Partitions/AppleMap.cs @@ -227,10 +227,10 @@ namespace DiscImageChef.PartPlugins APMEntry.sectors = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x0C); cString = new byte[32]; Array.Copy(APMEntry_sector, 0x10, cString, 0, 32); - APMEntry.name = StringHandlers.CToString(cString); + APMEntry.name = StringHandlers.CToString(cString, Encoding.GetEncoding("macintosh")); cString = new byte[32]; Array.Copy(APMEntry_sector, 0x30, cString, 0, 32); - APMEntry.type = StringHandlers.CToString(cString); + APMEntry.type = StringHandlers.CToString(cString, Encoding.GetEncoding("macintosh")); APMEntry.first_data_block = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x50); APMEntry.data_sectors = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x54); APMEntry.status = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x58); @@ -243,7 +243,7 @@ namespace DiscImageChef.PartPlugins APMEntry.checksum = BigEndianBitConverter.ToUInt32(APMEntry_sector, 0x74); cString = new byte[16]; Array.Copy(APMEntry_sector, 0x78, cString, 0, 16); - APMEntry.processor = StringHandlers.CToString(cString); + APMEntry.processor = StringHandlers.CToString(cString, Encoding.GetEncoding("macintosh")); return APMEntry; } diff --git a/DiscImageChef.Partitions/RDB.cs b/DiscImageChef.Partitions/RDB.cs index 9af92983..da156552 100644 --- a/DiscImageChef.Partitions/RDB.cs +++ b/DiscImageChef.Partitions/RDB.cs @@ -1,4 +1,4 @@ -// /*************************************************************************** +// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // @@ -1132,7 +1132,7 @@ namespace DiscImageChef.PartPlugins partEntry.devFlags = BigEndianBitConverter.ToUInt32(sector, 0x20); partEntry.driveNameLen = sector[0x24]; Array.Copy(sector, 0x24, driveName, 0, 32); - partEntry.driveName = StringHandlers.PascalToString(driveName); + partEntry.driveName = StringHandlers.PascalToString(driveName, Encoding.GetEncoding("iso-8859-1")); partEntry.reserved3 = BigEndianBitConverter.ToUInt32(sector, 0x44); partEntry.reserved4 = BigEndianBitConverter.ToUInt32(sector, 0x48); partEntry.reserved5 = BigEndianBitConverter.ToUInt32(sector, 0x4C);