diff --git a/Claunia.Encoding.Tests/ATASCII.cs b/Claunia.Encoding.Tests/ATASCII.cs index 33f693e..159bc38 100644 --- a/Claunia.Encoding.Tests/ATASCII.cs +++ b/Claunia.Encoding.Tests/ATASCII.cs @@ -26,105 +26,104 @@ using NUnit.Framework; -namespace Claunia.Encoding.Tests +namespace Claunia.Encoding.Tests; + +[TestFixture] +public class Atascii { - [TestFixture] - public class Atascii + const string PUNCTUATIONS = "!\"#$%&'()*+,-./:;<=>?@[\\]^_|"; + readonly byte[] _punctuationsBytes = { - const string PUNCTUATIONS = "!\"#$%&'()*+,-./:;<=>?@[\\]^_|"; - readonly byte[] _punctuationsBytes = - { - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, - 0x3D, 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7C - }; - const string DIGITS = "0123456789"; - readonly byte[] _digitsBytes = - { - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 - }; - const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - readonly byte[] _upperLatinBytes = - { - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, - 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A - }; - const string LOWER_LATIN = "abcdefghijklmnopqrstuvwxyz"; - readonly byte[] _lowerLatinBytes = - { - 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, - 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A - }; + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, + 0x3D, 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7C + }; + const string DIGITS = "0123456789"; + readonly byte[] _digitsBytes = + { + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 + }; + const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + readonly byte[] _upperLatinBytes = + { + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, + 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A + }; + const string LOWER_LATIN = "abcdefghijklmnopqrstuvwxyz"; + readonly byte[] _lowerLatinBytes = + { + 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, + 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A + }; - const string GRAPHICS = "├┘┤┐╱╲◢▗◣▝▘▂▖┌─┼●▄▎┬┴▌└"; - readonly byte[] _graphicsBytes = - { - 0x01, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0E, 0x0F, 0x11, 0x12, 0x13, 0x14, 0x15, - 0x16, 0x17, 0x18, 0x19, 0x1A - }; - const string ARROWS = "↑↓←→🢰◀▶"; - readonly byte[] _arrowsBytes = - { - 0x1C, 0x1D, 0x1E, 0x1F, 0x7D, 0x7E, 0x7F - }; - const string DECKS = "♥♣♦♠"; - readonly byte[] _decksBytes = - { - 0x00, 0x10, 0x60, 0x7B - }; + const string GRAPHICS = "├┘┤┐╱╲◢▗◣▝▘▂▖┌─┼●▄▎┬┴▌└"; + readonly byte[] _graphicsBytes = + { + 0x01, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0E, 0x0F, 0x11, 0x12, 0x13, 0x14, 0x15, + 0x16, 0x17, 0x18, 0x19, 0x1A + }; + const string ARROWS = "↑↓←→🢰◀▶"; + readonly byte[] _arrowsBytes = + { + 0x1C, 0x1D, 0x1E, 0x1F, 0x7D, 0x7E, 0x7F + }; + const string DECKS = "♥♣♦♠"; + readonly byte[] _decksBytes = + { + 0x00, 0x10, 0x60, 0x7B + }; - [Test] - public void AtariPangrams() - { - byte[] byteArray; - string testString; + [Test] + public void AtariPangrams() + { + byte[] byteArray; + string testString; - byteArray = Encoding.AtariEncoding.GetBytes(Pangrams.ENGLISH); - testString = Encoding.AtariEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.ENGLISH, testString); - } + byteArray = Encoding.AtariEncoding.GetBytes(Pangrams.ENGLISH); + testString = Encoding.AtariEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.ENGLISH, testString); + } - [Test] - public void AtariToUnicode() - { - string testString; + [Test] + public void AtariToUnicode() + { + string testString; - testString = Encoding.AtariEncoding.GetString(_punctuationsBytes); - Assert.AreEqual(PUNCTUATIONS, testString); - testString = Encoding.AtariEncoding.GetString(_digitsBytes); - Assert.AreEqual(DIGITS, testString); - testString = Encoding.AtariEncoding.GetString(_upperLatinBytes); - Assert.AreEqual(UPPER_LATIN, testString); - testString = Encoding.AtariEncoding.GetString(_lowerLatinBytes); - Assert.AreEqual(LOWER_LATIN, testString); + testString = Encoding.AtariEncoding.GetString(_punctuationsBytes); + Assert.AreEqual(PUNCTUATIONS, testString); + testString = Encoding.AtariEncoding.GetString(_digitsBytes); + Assert.AreEqual(DIGITS, testString); + testString = Encoding.AtariEncoding.GetString(_upperLatinBytes); + Assert.AreEqual(UPPER_LATIN, testString); + testString = Encoding.AtariEncoding.GetString(_lowerLatinBytes); + Assert.AreEqual(LOWER_LATIN, testString); - testString = Encoding.AtariEncoding.GetString(_graphicsBytes); - Assert.AreEqual(GRAPHICS, testString); - testString = Encoding.AtariEncoding.GetString(_arrowsBytes); - Assert.AreEqual(ARROWS, testString); - testString = Encoding.AtariEncoding.GetString(_decksBytes); - Assert.AreEqual(DECKS, testString); - } + testString = Encoding.AtariEncoding.GetString(_graphicsBytes); + Assert.AreEqual(GRAPHICS, testString); + testString = Encoding.AtariEncoding.GetString(_arrowsBytes); + Assert.AreEqual(ARROWS, testString); + testString = Encoding.AtariEncoding.GetString(_decksBytes); + Assert.AreEqual(DECKS, testString); + } - [Test] - public void UnicodeToAtari() - { - byte[] byteArray; + [Test] + public void UnicodeToAtari() + { + byte[] byteArray; - byteArray = Encoding.AtariEncoding.GetBytes(PUNCTUATIONS); - Assert.AreEqual(_punctuationsBytes, byteArray); - byteArray = Encoding.AtariEncoding.GetBytes(DIGITS); - Assert.AreEqual(_digitsBytes, byteArray); - byteArray = Encoding.AtariEncoding.GetBytes(UPPER_LATIN); - Assert.AreEqual(_upperLatinBytes, byteArray); - byteArray = Encoding.AtariEncoding.GetBytes(LOWER_LATIN); - Assert.AreEqual(_lowerLatinBytes, byteArray); + byteArray = Encoding.AtariEncoding.GetBytes(PUNCTUATIONS); + Assert.AreEqual(_punctuationsBytes, byteArray); + byteArray = Encoding.AtariEncoding.GetBytes(DIGITS); + Assert.AreEqual(_digitsBytes, byteArray); + byteArray = Encoding.AtariEncoding.GetBytes(UPPER_LATIN); + Assert.AreEqual(_upperLatinBytes, byteArray); + byteArray = Encoding.AtariEncoding.GetBytes(LOWER_LATIN); + Assert.AreEqual(_lowerLatinBytes, byteArray); - byteArray = Encoding.AtariEncoding.GetBytes(GRAPHICS); - Assert.AreEqual(_graphicsBytes, byteArray); - byteArray = Encoding.AtariEncoding.GetBytes(ARROWS); - Assert.AreEqual(_arrowsBytes, byteArray); - byteArray = Encoding.AtariEncoding.GetBytes(DECKS); - Assert.AreEqual(_decksBytes, byteArray); - } + byteArray = Encoding.AtariEncoding.GetBytes(GRAPHICS); + Assert.AreEqual(_graphicsBytes, byteArray); + byteArray = Encoding.AtariEncoding.GetBytes(ARROWS); + Assert.AreEqual(_arrowsBytes, byteArray); + byteArray = Encoding.AtariEncoding.GetBytes(DECKS); + Assert.AreEqual(_decksBytes, byteArray); } } \ No newline at end of file diff --git a/Claunia.Encoding.Tests/AtariST.cs b/Claunia.Encoding.Tests/AtariST.cs index 3424973..678e350 100644 --- a/Claunia.Encoding.Tests/AtariST.cs +++ b/Claunia.Encoding.Tests/AtariST.cs @@ -26,236 +26,235 @@ using NUnit.Framework; -namespace Claunia.Encoding.Tests +namespace Claunia.Encoding.Tests; + +[TestFixture] +public class AtariSt { - [TestFixture] - public class AtariSt + const string PUNCTUATIONS = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; + readonly byte[] _punctuationsBytes = { - const string PUNCTUATIONS = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; - readonly byte[] _punctuationsBytes = - { - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, - 0x3D, 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x7B, 0x7C, 0x7D, 0x7E - }; - const string DIGITS = "0123456789"; - readonly byte[] _digitsBytes = - { - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 - }; - const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - readonly byte[] _upperLatinBytes = - { - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, - 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A - }; - const string LOWER_LATIN = "abcdefghijklmnopqrstuvwxyz"; - readonly byte[] _lowerLatinBytes = - { - 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, - 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A - }; + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, + 0x3D, 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x7B, 0x7C, 0x7D, 0x7E + }; + const string DIGITS = "0123456789"; + readonly byte[] _digitsBytes = + { + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 + }; + const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + readonly byte[] _upperLatinBytes = + { + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, + 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A + }; + const string LOWER_LATIN = "abcdefghijklmnopqrstuvwxyz"; + readonly byte[] _lowerLatinBytes = + { + 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, + 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A + }; - const string SPANISH = "¡¿áéíóúüñÉÜÑ"; - readonly byte[] _spanishBytes = - { - 0xAD, 0xA8, 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x81, 0xA4, 0x90, 0x9A, 0xA5 - }; - const string FRENCH = "éÉàèùÀâêîôûëïüÿçÇœŒæÆ"; - readonly byte[] _frenchBytes = - { - 0x82, 0x90, 0x85, 0x8A, 0x97, 0xB6, 0x83, 0x88, 0x8C, 0x93, 0x96, 0x89, 0x8B, 0x81, 0x98, 0x87, 0x80, 0xB4, - 0xB5, 0x91, 0x92 - }; - const string GERMAN = "äöüßÄÖÜ"; - readonly byte[] _germanBytes = - { - 0x84, 0x94, 0x81, 0x9E, 0x8E, 0x99, 0x9A - }; - const string NORWEGIAN = "æøåÆØÅ"; - readonly byte[] _norwegianBytes = - { - 0x91, 0xB3, 0x86, 0x92, 0xB2, 0x8F - }; - const string PORTUGUESE = "áéíóúÉâêôãõÃÕçÇ"; - readonly byte[] _portugueseBytes = - { - 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x90, 0x83, 0x88, 0x93, 0xB0, 0xB1, 0xB7, 0xB8, 0x87, 0x80 - }; - const string DUTCH = "ijIJ"; - readonly byte[] _dutchBytes = - { - 0xC0, 0xC1 - }; - const string HEBREW = "אבגדהוזחטיכלמנסעפצקרשתןךםףץ"; - readonly byte[] _hebrewBytes = - { - 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, - 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC - }; - const string GREEK = "αβΓπΣσµτΦΘΩδ¯"; - readonly byte[] _greekBytes = - { - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xFF - }; + const string SPANISH = "¡¿áéíóúüñÉÜÑ"; + readonly byte[] _spanishBytes = + { + 0xAD, 0xA8, 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x81, 0xA4, 0x90, 0x9A, 0xA5 + }; + const string FRENCH = "éÉàèùÀâêîôûëïüÿçÇœŒæÆ"; + readonly byte[] _frenchBytes = + { + 0x82, 0x90, 0x85, 0x8A, 0x97, 0xB6, 0x83, 0x88, 0x8C, 0x93, 0x96, 0x89, 0x8B, 0x81, 0x98, 0x87, 0x80, 0xB4, + 0xB5, 0x91, 0x92 + }; + const string GERMAN = "äöüßÄÖÜ"; + readonly byte[] _germanBytes = + { + 0x84, 0x94, 0x81, 0x9E, 0x8E, 0x99, 0x9A + }; + const string NORWEGIAN = "æøåÆØÅ"; + readonly byte[] _norwegianBytes = + { + 0x91, 0xB3, 0x86, 0x92, 0xB2, 0x8F + }; + const string PORTUGUESE = "áéíóúÉâêôãõÃÕçÇ"; + readonly byte[] _portugueseBytes = + { + 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x90, 0x83, 0x88, 0x93, 0xB0, 0xB1, 0xB7, 0xB8, 0x87, 0x80 + }; + const string DUTCH = "ijIJ"; + readonly byte[] _dutchBytes = + { + 0xC0, 0xC1 + }; + const string HEBREW = "אבגדהוזחטיכלמנסעפצקרשתןךםףץ"; + readonly byte[] _hebrewBytes = + { + 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, + 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC + }; + const string GREEK = "αβΓπΣσµτΦΘΩδ¯"; + readonly byte[] _greekBytes = + { + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xFF + }; - const string TYPOGRAPHIC = "ªº«»¨´†¶©®™§°∙·"; - readonly byte[] _typographicBytes = - { - 0xA6, 0xA7, 0xAE, 0xAF, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xDD, 0xF8, 0xF9, 0xFA - }; - const string CURRENCY = "¢£¥ƒ"; - readonly byte[] _currencyBytes = - { - 0x9B, 0x9C, 0x9D, 0x9F - }; - const string MATHEMATICS = "⌐¬½¼∧∞∮ϕ∈∩≡±≥≤⌠⌡÷≈√ⁿ²³"; - readonly byte[] _mathematicsBytes = - { - 0xA9, 0xAA, 0xAB, 0xAC, 0xDE, 0xDF, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - 0xFB, 0xFC, 0xFD, 0xFE - }; - const string SYMBOLS = "⇧⇩⇨⇦🮽✓♪ə"; - readonly byte[] _symbolsBytes = - { - 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x0B, 0x1A - }; + const string TYPOGRAPHIC = "ªº«»¨´†¶©®™§°∙·"; + readonly byte[] _typographicBytes = + { + 0xA6, 0xA7, 0xAE, 0xAF, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xDD, 0xF8, 0xF9, 0xFA + }; + const string CURRENCY = "¢£¥ƒ"; + readonly byte[] _currencyBytes = + { + 0x9B, 0x9C, 0x9D, 0x9F + }; + const string MATHEMATICS = "⌐¬½¼∧∞∮ϕ∈∩≡±≥≤⌠⌡÷≈√ⁿ²³"; + readonly byte[] _mathematicsBytes = + { + 0xA9, 0xAA, 0xAB, 0xAC, 0xDE, 0xDF, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xFB, 0xFC, 0xFD, 0xFE + }; + const string SYMBOLS = "⇧⇩⇨⇦🮽✓♪ə"; + readonly byte[] _symbolsBytes = + { + 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x0B, 0x1A + }; - [Test] - public void AtariStPangrams() - { - byte[] byteArray; - string testString; + [Test] + public void AtariStPangrams() + { + byte[] byteArray; + string testString; - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.BASQUE); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.BASQUE, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.DANISH); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.DANISH, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.ENGLISH); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.ENGLISH, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.FINNISH); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.FINNISH, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.FRENCH); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.FRENCH, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.GALICIAN); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.GALICIAN, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.GERMAN); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.GERMAN, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.HEBREW); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.HEBREW, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.NORWEGIAN); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.NORWEGIAN, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.PORTUGUESE); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.PORTUGUESE, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.SPANISH); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.SPANISH, testString); - byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.SWEDISH); - testString = Encoding.AtariStEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.SWEDISH, testString); - } + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.BASQUE); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.BASQUE, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.DANISH); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.DANISH, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.ENGLISH); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.ENGLISH, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.FINNISH); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.FINNISH, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.FRENCH); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.FRENCH, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.GALICIAN); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.GALICIAN, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.GERMAN); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.GERMAN, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.HEBREW); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.HEBREW, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.NORWEGIAN); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.NORWEGIAN, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.PORTUGUESE); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.PORTUGUESE, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.SPANISH); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.SPANISH, testString); + byteArray = Encoding.AtariStEncoding.GetBytes(Pangrams.SWEDISH); + testString = Encoding.AtariStEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.SWEDISH, testString); + } - [Test] - public void AtariStToUnicode() - { - string testString; + [Test] + public void AtariStToUnicode() + { + string testString; - testString = Encoding.AtariStEncoding.GetString(_punctuationsBytes); - Assert.AreEqual(PUNCTUATIONS, testString); - testString = Encoding.AtariStEncoding.GetString(_digitsBytes); - Assert.AreEqual(DIGITS, testString); - testString = Encoding.AtariStEncoding.GetString(_upperLatinBytes); - Assert.AreEqual(UPPER_LATIN, testString); - testString = Encoding.AtariStEncoding.GetString(_lowerLatinBytes); - Assert.AreEqual(LOWER_LATIN, testString); + testString = Encoding.AtariStEncoding.GetString(_punctuationsBytes); + Assert.AreEqual(PUNCTUATIONS, testString); + testString = Encoding.AtariStEncoding.GetString(_digitsBytes); + Assert.AreEqual(DIGITS, testString); + testString = Encoding.AtariStEncoding.GetString(_upperLatinBytes); + Assert.AreEqual(UPPER_LATIN, testString); + testString = Encoding.AtariStEncoding.GetString(_lowerLatinBytes); + Assert.AreEqual(LOWER_LATIN, testString); - testString = Encoding.AtariStEncoding.GetString(_spanishBytes); - Assert.AreEqual(SPANISH, testString); - testString = Encoding.AtariStEncoding.GetString(_frenchBytes); - Assert.AreEqual(FRENCH, testString); - testString = Encoding.AtariStEncoding.GetString(_germanBytes); - Assert.AreEqual(GERMAN, testString); - testString = Encoding.AtariStEncoding.GetString(_norwegianBytes); - Assert.AreEqual(NORWEGIAN, testString); - testString = Encoding.AtariStEncoding.GetString(_portugueseBytes); - Assert.AreEqual(PORTUGUESE, testString); - testString = Encoding.AtariStEncoding.GetString(_dutchBytes); - Assert.AreEqual(DUTCH, testString); - testString = Encoding.AtariStEncoding.GetString(_hebrewBytes); - Assert.AreEqual(HEBREW, testString); - testString = Encoding.AtariStEncoding.GetString(_greekBytes); - Assert.AreEqual(GREEK, testString); + testString = Encoding.AtariStEncoding.GetString(_spanishBytes); + Assert.AreEqual(SPANISH, testString); + testString = Encoding.AtariStEncoding.GetString(_frenchBytes); + Assert.AreEqual(FRENCH, testString); + testString = Encoding.AtariStEncoding.GetString(_germanBytes); + Assert.AreEqual(GERMAN, testString); + testString = Encoding.AtariStEncoding.GetString(_norwegianBytes); + Assert.AreEqual(NORWEGIAN, testString); + testString = Encoding.AtariStEncoding.GetString(_portugueseBytes); + Assert.AreEqual(PORTUGUESE, testString); + testString = Encoding.AtariStEncoding.GetString(_dutchBytes); + Assert.AreEqual(DUTCH, testString); + testString = Encoding.AtariStEncoding.GetString(_hebrewBytes); + Assert.AreEqual(HEBREW, testString); + testString = Encoding.AtariStEncoding.GetString(_greekBytes); + Assert.AreEqual(GREEK, testString); - testString = Encoding.AtariStEncoding.GetString(_typographicBytes); - Assert.AreEqual(TYPOGRAPHIC, testString); - testString = Encoding.AtariStEncoding.GetString(_currencyBytes); - Assert.AreEqual(CURRENCY, testString); - testString = Encoding.AtariStEncoding.GetString(_mathematicsBytes); - Assert.AreEqual(MATHEMATICS, testString); - testString = Encoding.AtariStEncoding.GetString(_symbolsBytes); - Assert.AreEqual(SYMBOLS, testString); - - // TODO: 0x09 => U+1F552, 0x0A => U+1F514 - /*testString = Encoding.AtariSTEncoding.GetString(SymbolsUnicode32Bytes); - Assert.AreEqual(SymbolsUnicode32, testString);*/ - } + testString = Encoding.AtariStEncoding.GetString(_typographicBytes); + Assert.AreEqual(TYPOGRAPHIC, testString); + testString = Encoding.AtariStEncoding.GetString(_currencyBytes); + Assert.AreEqual(CURRENCY, testString); + testString = Encoding.AtariStEncoding.GetString(_mathematicsBytes); + Assert.AreEqual(MATHEMATICS, testString); + testString = Encoding.AtariStEncoding.GetString(_symbolsBytes); + Assert.AreEqual(SYMBOLS, testString); // TODO: 0x09 => U+1F552, 0x0A => U+1F514 - /*const string SymbolsUnicode32 = "\ud83d\udd52\ud83d\udd14"; - readonly byte[] SymbolsUnicode32Bytes = { 0x09, 0x0A };*/ + /*testString = Encoding.AtariSTEncoding.GetString(SymbolsUnicode32Bytes); + Assert.AreEqual(SymbolsUnicode32, testString);*/ + } - [Test] - public void UnicodeToAtariSt() - { - byte[] byteArray; + // TODO: 0x09 => U+1F552, 0x0A => U+1F514 + /*const string SymbolsUnicode32 = "\ud83d\udd52\ud83d\udd14"; + readonly byte[] SymbolsUnicode32Bytes = { 0x09, 0x0A };*/ - byteArray = Encoding.AtariStEncoding.GetBytes(PUNCTUATIONS); - Assert.AreEqual(_punctuationsBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(DIGITS); - Assert.AreEqual(_digitsBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(UPPER_LATIN); - Assert.AreEqual(_upperLatinBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(LOWER_LATIN); - Assert.AreEqual(_lowerLatinBytes, byteArray); + [Test] + public void UnicodeToAtariSt() + { + byte[] byteArray; - byteArray = Encoding.AtariStEncoding.GetBytes(SPANISH); - Assert.AreEqual(_spanishBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(FRENCH); - Assert.AreEqual(_frenchBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(GERMAN); - Assert.AreEqual(_germanBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(NORWEGIAN); - Assert.AreEqual(_norwegianBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(PORTUGUESE); - Assert.AreEqual(_portugueseBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(DUTCH); - Assert.AreEqual(_dutchBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(HEBREW); - Assert.AreEqual(_hebrewBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(GREEK); - Assert.AreEqual(_greekBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(PUNCTUATIONS); + Assert.AreEqual(_punctuationsBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(DIGITS); + Assert.AreEqual(_digitsBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(UPPER_LATIN); + Assert.AreEqual(_upperLatinBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(LOWER_LATIN); + Assert.AreEqual(_lowerLatinBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(TYPOGRAPHIC); - Assert.AreEqual(_typographicBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(CURRENCY); - Assert.AreEqual(_currencyBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(MATHEMATICS); - Assert.AreEqual(_mathematicsBytes, byteArray); - byteArray = Encoding.AtariStEncoding.GetBytes(SYMBOLS); - Assert.AreEqual(_symbolsBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(SPANISH); + Assert.AreEqual(_spanishBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(FRENCH); + Assert.AreEqual(_frenchBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(GERMAN); + Assert.AreEqual(_germanBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(NORWEGIAN); + Assert.AreEqual(_norwegianBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(PORTUGUESE); + Assert.AreEqual(_portugueseBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(DUTCH); + Assert.AreEqual(_dutchBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(HEBREW); + Assert.AreEqual(_hebrewBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(GREEK); + Assert.AreEqual(_greekBytes, byteArray); - // TODO: 0x09 => U+1F552, 0x0A => U+1F514 - /*byteArray = Encoding.AtariSTEncoding.GetBytes(SymbolsUnicode32); - Assert.AreEqual(SymbolsUnicode32Bytes, byteArray);*/ - } + byteArray = Encoding.AtariStEncoding.GetBytes(TYPOGRAPHIC); + Assert.AreEqual(_typographicBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(CURRENCY); + Assert.AreEqual(_currencyBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(MATHEMATICS); + Assert.AreEqual(_mathematicsBytes, byteArray); + byteArray = Encoding.AtariStEncoding.GetBytes(SYMBOLS); + Assert.AreEqual(_symbolsBytes, byteArray); + + // TODO: 0x09 => U+1F552, 0x0A => U+1F514 + /*byteArray = Encoding.AtariSTEncoding.GetBytes(SymbolsUnicode32); + Assert.AreEqual(SymbolsUnicode32Bytes, byteArray);*/ } } \ No newline at end of file diff --git a/Claunia.Encoding.Tests/GetEncs.cs b/Claunia.Encoding.Tests/GetEncs.cs index 84e73e9..ee19df7 100644 --- a/Claunia.Encoding.Tests/GetEncs.cs +++ b/Claunia.Encoding.Tests/GetEncs.cs @@ -27,48 +27,47 @@ using System; using NUnit.Framework; -namespace Claunia.Encoding.Tests +namespace Claunia.Encoding.Tests; + +[TestFixture] +public class GetEncs { - [TestFixture] - public class GetEncs + [Test] + + // Well basically this is taken from MSDN's documentation :p + public void GetAllEncs() { - [Test] + // Print the header. + Console.Write("CodePage identifier and name "); + Console.Write("BrDisp BrSave "); + Console.Write("MNDisp MNSave "); + Console.WriteLine("1-Byte ReadOnly "); - // Well basically this is taken from MSDN's documentation :p - public void GetAllEncs() + // For every encoding, get the property values. + foreach(EncodingInfo ei in Encoding.GetEncodings()) { - // Print the header. - Console.Write("CodePage identifier and name "); - Console.Write("BrDisp BrSave "); - Console.Write("MNDisp MNSave "); - Console.WriteLine("1-Byte ReadOnly "); + Encoding e = ei.GetEncoding(); - // For every encoding, get the property values. - foreach(EncodingInfo ei in Encoding.GetEncodings()) - { - Encoding e = ei.GetEncoding(); - - Console.Write("{0,-6} {1,-25} ", ei.CodePage, ei.Name); - Console.Write("{0,-8} {1,-8} ", e.IsBrowserDisplay, e.IsBrowserSave); - Console.Write("{0,-8} {1,-8} ", e.IsMailNewsDisplay, e.IsMailNewsSave); - Console.WriteLine("{0,-8} {1,-8} ", e.IsSingleByte, e.IsReadOnly); - } - } - - [Test] - - // Well basically this is taken from MSDN's documentation :p - public void GetExternalEncoding() - { - System.Text.Encoding e = Encoding.GetEncoding("iso8859-1"); - } - - [Test] - - // Well basically this is taken from MSDN's documentation :p - public void GetInternalEncoding() - { - System.Text.Encoding e = Encoding.GetEncoding("lisa"); + Console.Write("{0,-6} {1,-25} ", ei.CodePage, ei.Name); + Console.Write("{0,-8} {1,-8} ", e.IsBrowserDisplay, e.IsBrowserSave); + Console.Write("{0,-8} {1,-8} ", e.IsMailNewsDisplay, e.IsMailNewsSave); + Console.WriteLine("{0,-8} {1,-8} ", e.IsSingleByte, e.IsReadOnly); } } + + [Test] + + // Well basically this is taken from MSDN's documentation :p + public void GetExternalEncoding() + { + System.Text.Encoding e = Encoding.GetEncoding("iso8859-1"); + } + + [Test] + + // Well basically this is taken from MSDN's documentation :p + public void GetInternalEncoding() + { + System.Text.Encoding e = Encoding.GetEncoding("lisa"); + } } \ No newline at end of file diff --git a/Claunia.Encoding.Tests/LisaRoman.cs b/Claunia.Encoding.Tests/LisaRoman.cs index 236c6ab..b33facd 100644 --- a/Claunia.Encoding.Tests/LisaRoman.cs +++ b/Claunia.Encoding.Tests/LisaRoman.cs @@ -26,191 +26,190 @@ using NUnit.Framework; -namespace Claunia.Encoding.Tests +namespace Claunia.Encoding.Tests; + +[TestFixture] +public class LisaRoman { - [TestFixture] - public class LisaRoman + const string PUNCTUATIONS = "!\"#$%&()*+,-./:;<=>?@[\\]^_{|}~"; + readonly byte[] _punctuationsBytes = { - const string PUNCTUATIONS = "!\"#$%&()*+,-./:;<=>?@[\\]^_{|}~"; - readonly byte[] _punctuationsBytes = - { - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, - 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7B, 0x7C, 0x7D, 0x7E - }; - const string DIGITS = "0123456789"; - readonly byte[] _digitsBytes = - { - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 - }; - const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - readonly byte[] _upperLatinBytes = - { - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, - 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A - }; - const string LOWER_LATIN = "abcdefghijklmnopqrstuvwxyz"; - readonly byte[] _lowerLatinBytes = - { - 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, - 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A - }; + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, + 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7B, 0x7C, 0x7D, 0x7E + }; + const string DIGITS = "0123456789"; + readonly byte[] _digitsBytes = + { + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 + }; + const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + readonly byte[] _upperLatinBytes = + { + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, + 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A + }; + const string LOWER_LATIN = "abcdefghijklmnopqrstuvwxyz"; + readonly byte[] _lowerLatinBytes = + { + 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, + 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A + }; - const string SPANISH = "¡¿áéíóúüñÉÜÑ"; - readonly byte[] _spanishBytes = - { - 0xC1, 0xC0, 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x9F, 0x96, 0x83, 0x86, 0x84 - }; - const string FRENCH = "éÉàèùÀâêîôûëïüÿçÇœŒæÆ"; - readonly byte[] _frenchBytes = - { - 0x8E, 0x83, 0x88, 0x8F, 0x9D, 0xCB, 0x89, 0x90, 0x94, 0x99, 0x9E, 0x91, 0x95, 0x9F, 0xD8, 0x8D, 0x82, 0xCF, - 0xCE, 0xBE, 0xAE - }; - const string GERMAN = "äöüßÄÖÜ"; - readonly byte[] _germanBytes = - { - 0x8A, 0x9A, 0x9F, 0xA7, 0x80, 0x85, 0x86 - }; - const string NORWEGIAN = "æøåÆØÅ"; - readonly byte[] _norwegianBytes = - { - 0xBE, 0xBF, 0x8C, 0xAE, 0xAF, 0x81 - }; - const string PORTUGUESE = "áéíóúÉâêôãõÃÕçÇ"; - readonly byte[] _portugueseBytes = - { - 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x83, 0x89, 0x90, 0x99, 0x8B, 0x9B, 0xCC, 0xCD, 0x8D, 0x82 - }; + const string SPANISH = "¡¿áéíóúüñÉÜÑ"; + readonly byte[] _spanishBytes = + { + 0xC1, 0xC0, 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x9F, 0x96, 0x83, 0x86, 0x84 + }; + const string FRENCH = "éÉàèùÀâêîôûëïüÿçÇœŒæÆ"; + readonly byte[] _frenchBytes = + { + 0x8E, 0x83, 0x88, 0x8F, 0x9D, 0xCB, 0x89, 0x90, 0x94, 0x99, 0x9E, 0x91, 0x95, 0x9F, 0xD8, 0x8D, 0x82, 0xCF, + 0xCE, 0xBE, 0xAE + }; + const string GERMAN = "äöüßÄÖÜ"; + readonly byte[] _germanBytes = + { + 0x8A, 0x9A, 0x9F, 0xA7, 0x80, 0x85, 0x86 + }; + const string NORWEGIAN = "æøåÆØÅ"; + readonly byte[] _norwegianBytes = + { + 0xBE, 0xBF, 0x8C, 0xAE, 0xAF, 0x81 + }; + const string PORTUGUESE = "áéíóúÉâêôãõÃÕçÇ"; + readonly byte[] _portugueseBytes = + { + 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x83, 0x89, 0x90, 0x99, 0x8B, 0x9B, 0xCC, 0xCD, 0x8D, 0x82 + }; - const string TYPOGRAPHIC = "†°•¶®©™´¨ªº«»…–—“”‘’§"; - readonly byte[] _typographicBytes = - { - 0xA0, 0xA1, 0xA5, 0xA6, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xBB, 0xBC, 0xC7, 0xC8, 0xC9, 0xD0, 0xD1, 0xD2, 0xD3, - 0xD4, 0xD5, 0xA4 - }; - const string CURRENCY = "¢£¥"; - readonly byte[] _currencyBytes = - { - 0xA2, 0xA3, 0xB4 - }; - const string MATHEMATICS = "≠∞±≤≥µ∂∑∏π∫Ω¬√ƒ≈∆÷◊"; - readonly byte[] _mathematicsBytes = - { - 0xAD, 0xB0, 0xB1, 0xB2, 0xB3, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBD, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xD6, - 0xD7 - }; + const string TYPOGRAPHIC = "†°•¶®©™´¨ªº«»…–—“”‘’§"; + readonly byte[] _typographicBytes = + { + 0xA0, 0xA1, 0xA5, 0xA6, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xBB, 0xBC, 0xC7, 0xC8, 0xC9, 0xD0, 0xD1, 0xD2, 0xD3, + 0xD4, 0xD5, 0xA4 + }; + const string CURRENCY = "¢£¥"; + readonly byte[] _currencyBytes = + { + 0xA2, 0xA3, 0xB4 + }; + const string MATHEMATICS = "≠∞±≤≥µ∂∑∏π∫Ω¬√ƒ≈∆÷◊"; + readonly byte[] _mathematicsBytes = + { + 0xAD, 0xB0, 0xB1, 0xB2, 0xB3, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBD, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xD6, + 0xD7 + }; - [Test] - public void LisaPangrams() - { - byte[] byteArray; - string testString; + [Test] + public void LisaPangrams() + { + byte[] byteArray; + string testString; - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.BASQUE); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.BASQUE, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.BRETON); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.BRETON, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.DANISH); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.DANISH, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.DUTCH); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.DUTCH, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.ENGLISH); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.ENGLISH, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.FINNISH); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.FINNISH, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.FRENCH); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.FRENCH, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.GALICIAN); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.GALICIAN, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.GERMAN); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.GERMAN, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.NORWEGIAN); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.NORWEGIAN, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.PORTUGUESE); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.PORTUGUESE, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.SPANISH); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.SPANISH, testString); - byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.SWEDISH); - testString = Encoding.LisaEncoding.GetString(byteArray); - Assert.AreEqual(Pangrams.SWEDISH, testString); - } + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.BASQUE); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.BASQUE, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.BRETON); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.BRETON, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.DANISH); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.DANISH, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.DUTCH); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.DUTCH, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.ENGLISH); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.ENGLISH, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.FINNISH); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.FINNISH, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.FRENCH); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.FRENCH, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.GALICIAN); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.GALICIAN, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.GERMAN); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.GERMAN, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.NORWEGIAN); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.NORWEGIAN, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.PORTUGUESE); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.PORTUGUESE, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.SPANISH); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.SPANISH, testString); + byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.SWEDISH); + testString = Encoding.LisaEncoding.GetString(byteArray); + Assert.AreEqual(Pangrams.SWEDISH, testString); + } - [Test] - public void LisaToUnicode() - { - string testString; + [Test] + public void LisaToUnicode() + { + string testString; - testString = Encoding.LisaEncoding.GetString(_punctuationsBytes); - Assert.AreEqual(PUNCTUATIONS, testString); - testString = Encoding.LisaEncoding.GetString(_digitsBytes); - Assert.AreEqual(DIGITS, testString); - testString = Encoding.LisaEncoding.GetString(_upperLatinBytes); - Assert.AreEqual(UPPER_LATIN, testString); - testString = Encoding.LisaEncoding.GetString(_lowerLatinBytes); - Assert.AreEqual(LOWER_LATIN, testString); + testString = Encoding.LisaEncoding.GetString(_punctuationsBytes); + Assert.AreEqual(PUNCTUATIONS, testString); + testString = Encoding.LisaEncoding.GetString(_digitsBytes); + Assert.AreEqual(DIGITS, testString); + testString = Encoding.LisaEncoding.GetString(_upperLatinBytes); + Assert.AreEqual(UPPER_LATIN, testString); + testString = Encoding.LisaEncoding.GetString(_lowerLatinBytes); + Assert.AreEqual(LOWER_LATIN, testString); - testString = Encoding.LisaEncoding.GetString(_spanishBytes); - Assert.AreEqual(SPANISH, testString); - testString = Encoding.LisaEncoding.GetString(_frenchBytes); - Assert.AreEqual(FRENCH, testString); - testString = Encoding.LisaEncoding.GetString(_germanBytes); - Assert.AreEqual(GERMAN, testString); - testString = Encoding.LisaEncoding.GetString(_norwegianBytes); - Assert.AreEqual(NORWEGIAN, testString); - testString = Encoding.LisaEncoding.GetString(_portugueseBytes); - Assert.AreEqual(PORTUGUESE, testString); + testString = Encoding.LisaEncoding.GetString(_spanishBytes); + Assert.AreEqual(SPANISH, testString); + testString = Encoding.LisaEncoding.GetString(_frenchBytes); + Assert.AreEqual(FRENCH, testString); + testString = Encoding.LisaEncoding.GetString(_germanBytes); + Assert.AreEqual(GERMAN, testString); + testString = Encoding.LisaEncoding.GetString(_norwegianBytes); + Assert.AreEqual(NORWEGIAN, testString); + testString = Encoding.LisaEncoding.GetString(_portugueseBytes); + Assert.AreEqual(PORTUGUESE, testString); - testString = Encoding.LisaEncoding.GetString(_typographicBytes); - Assert.AreEqual(TYPOGRAPHIC, testString); - testString = Encoding.LisaEncoding.GetString(_currencyBytes); - Assert.AreEqual(CURRENCY, testString); - testString = Encoding.LisaEncoding.GetString(_mathematicsBytes); - Assert.AreEqual(MATHEMATICS, testString); - } + testString = Encoding.LisaEncoding.GetString(_typographicBytes); + Assert.AreEqual(TYPOGRAPHIC, testString); + testString = Encoding.LisaEncoding.GetString(_currencyBytes); + Assert.AreEqual(CURRENCY, testString); + testString = Encoding.LisaEncoding.GetString(_mathematicsBytes); + Assert.AreEqual(MATHEMATICS, testString); + } - [Test] - public void UnicodeToLisa() - { - byte[] byteArray; + [Test] + public void UnicodeToLisa() + { + byte[] byteArray; - byteArray = Encoding.LisaEncoding.GetBytes(PUNCTUATIONS); - Assert.AreEqual(_punctuationsBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(DIGITS); - Assert.AreEqual(_digitsBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(UPPER_LATIN); - Assert.AreEqual(_upperLatinBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(LOWER_LATIN); - Assert.AreEqual(_lowerLatinBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(PUNCTUATIONS); + Assert.AreEqual(_punctuationsBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(DIGITS); + Assert.AreEqual(_digitsBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(UPPER_LATIN); + Assert.AreEqual(_upperLatinBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(LOWER_LATIN); + Assert.AreEqual(_lowerLatinBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(SPANISH); - Assert.AreEqual(_spanishBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(FRENCH); - Assert.AreEqual(_frenchBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(GERMAN); - Assert.AreEqual(_germanBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(NORWEGIAN); - Assert.AreEqual(_norwegianBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(PORTUGUESE); - Assert.AreEqual(_portugueseBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(SPANISH); + Assert.AreEqual(_spanishBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(FRENCH); + Assert.AreEqual(_frenchBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(GERMAN); + Assert.AreEqual(_germanBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(NORWEGIAN); + Assert.AreEqual(_norwegianBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(PORTUGUESE); + Assert.AreEqual(_portugueseBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(TYPOGRAPHIC); - Assert.AreEqual(_typographicBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(CURRENCY); - Assert.AreEqual(_currencyBytes, byteArray); - byteArray = Encoding.LisaEncoding.GetBytes(MATHEMATICS); - Assert.AreEqual(_mathematicsBytes, byteArray); - } + byteArray = Encoding.LisaEncoding.GetBytes(TYPOGRAPHIC); + Assert.AreEqual(_typographicBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(CURRENCY); + Assert.AreEqual(_currencyBytes, byteArray); + byteArray = Encoding.LisaEncoding.GetBytes(MATHEMATICS); + Assert.AreEqual(_mathematicsBytes, byteArray); } } \ No newline at end of file diff --git a/Claunia.Encoding.Tests/Radix50.cs b/Claunia.Encoding.Tests/Radix50.cs index dbc63eb..4bb751c 100644 --- a/Claunia.Encoding.Tests/Radix50.cs +++ b/Claunia.Encoding.Tests/Radix50.cs @@ -26,64 +26,63 @@ using NUnit.Framework; -namespace Claunia.Encoding.Tests +namespace Claunia.Encoding.Tests; + +[TestFixture] +public class Radix50 { - [TestFixture] - public class Radix50 + const string PUNCTUATIONS = " .$%"; + readonly byte[] _punctuationsBytes = { - const string PUNCTUATIONS = " .$%"; - readonly byte[] _punctuationsBytes = - { - 0b00000001, 0b11000110, 0b11011101 - }; - const string DIGITS = "0123456789"; - readonly byte[] _digitsBytes = - { - 0b01111001, 0b11111000, 0b00100001, 0b10001010, 0b00111001, 0b00100101, 0b10011010, 0b01110000 - }; - const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - readonly byte[] _upperLatinBytes = - { - 0b00000100, 0b00100000, 0b11000100, 0b00010100, 0b01100001, 0b11001000, 0b00100100, 0b10100010, 0b11001100, - 0b00110100, 0b11100011, 0b11010000, 0b01000101, 0b00100100, 0b11010100, 0b01010101, 0b01100101, 0b11011000, - 0b01100101, 0b10100000 - }; - const string SENTENCE = "THIS IS A TEST$"; - const string SENTENCE_PADDED = "THIS IS A TEST$ "; // It gets space padded when decoding is not multiple - readonly byte[] _sentenceBytes = - { - 0b01010000, 0b10000010, 0b01010011, 0b00000000, 0b10010100, 0b11000000, 0b00000100, 0b00000101, 0b00000101, - 0b01001101, 0b01000110, 0b11000000 - }; + 0b00000001, 0b11000110, 0b11011101 + }; + const string DIGITS = "0123456789"; + readonly byte[] _digitsBytes = + { + 0b01111001, 0b11111000, 0b00100001, 0b10001010, 0b00111001, 0b00100101, 0b10011010, 0b01110000 + }; + const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + readonly byte[] _upperLatinBytes = + { + 0b00000100, 0b00100000, 0b11000100, 0b00010100, 0b01100001, 0b11001000, 0b00100100, 0b10100010, 0b11001100, + 0b00110100, 0b11100011, 0b11010000, 0b01000101, 0b00100100, 0b11010100, 0b01010101, 0b01100101, 0b11011000, + 0b01100101, 0b10100000 + }; + const string SENTENCE = "THIS IS A TEST$"; + const string SENTENCE_PADDED = "THIS IS A TEST$ "; // It gets space padded when decoding is not multiple + readonly byte[] _sentenceBytes = + { + 0b01010000, 0b10000010, 0b01010011, 0b00000000, 0b10010100, 0b11000000, 0b00000100, 0b00000101, 0b00000101, + 0b01001101, 0b01000110, 0b11000000 + }; - [Test] - public void RadixToUnicode() - { - string testString; + [Test] + public void RadixToUnicode() + { + string testString; - testString = Encoding.Radix50Encoding.GetString(_punctuationsBytes); - Assert.AreEqual(PUNCTUATIONS, testString); - testString = Encoding.Radix50Encoding.GetString(_digitsBytes); - Assert.AreEqual(DIGITS, testString); - testString = Encoding.Radix50Encoding.GetString(_upperLatinBytes); - Assert.AreEqual(UPPER_LATIN, testString); - testString = Encoding.Radix50Encoding.GetString(_sentenceBytes); - Assert.AreEqual(SENTENCE_PADDED, testString); - } + testString = Encoding.Radix50Encoding.GetString(_punctuationsBytes); + Assert.AreEqual(PUNCTUATIONS, testString); + testString = Encoding.Radix50Encoding.GetString(_digitsBytes); + Assert.AreEqual(DIGITS, testString); + testString = Encoding.Radix50Encoding.GetString(_upperLatinBytes); + Assert.AreEqual(UPPER_LATIN, testString); + testString = Encoding.Radix50Encoding.GetString(_sentenceBytes); + Assert.AreEqual(SENTENCE_PADDED, testString); + } - [Test] - public void UnicodeToRadix() - { - byte[] byteArray; + [Test] + public void UnicodeToRadix() + { + byte[] byteArray; - byteArray = Encoding.Radix50Encoding.GetBytes(PUNCTUATIONS); - Assert.AreEqual(_punctuationsBytes, byteArray); - byteArray = Encoding.Radix50Encoding.GetBytes(DIGITS); - Assert.AreEqual(_digitsBytes, byteArray); - byteArray = Encoding.Radix50Encoding.GetBytes(UPPER_LATIN); - Assert.AreEqual(_upperLatinBytes, byteArray); - byteArray = Encoding.Radix50Encoding.GetBytes(SENTENCE); - Assert.AreEqual(_sentenceBytes, byteArray); - } + byteArray = Encoding.Radix50Encoding.GetBytes(PUNCTUATIONS); + Assert.AreEqual(_punctuationsBytes, byteArray); + byteArray = Encoding.Radix50Encoding.GetBytes(DIGITS); + Assert.AreEqual(_digitsBytes, byteArray); + byteArray = Encoding.Radix50Encoding.GetBytes(UPPER_LATIN); + Assert.AreEqual(_upperLatinBytes, byteArray); + byteArray = Encoding.Radix50Encoding.GetBytes(SENTENCE); + Assert.AreEqual(_sentenceBytes, byteArray); } } \ No newline at end of file diff --git a/Claunia.Encoding/ATASCII.cs b/Claunia.Encoding/ATASCII.cs index dd66628..ad96d88 100644 --- a/Claunia.Encoding/ATASCII.cs +++ b/Claunia.Encoding/ATASCII.cs @@ -26,317 +26,316 @@ using System.Text; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an ATARI Standard Code for Information Interchange character encoding of Unicode characters. +public class ATASCII : SingleByteEncodingWithRunes { - /// Represents an ATARI Standard Code for Information Interchange character encoding of Unicode characters. - public class ATASCII : SingleByteEncodingWithRunes + /// + public override string BodyName => "atascii"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Atari Standard Code for Information Interchange"; + /// + public override string HeaderName => "atascii"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => true; + + /// The ATASCII to Unicode character map. + protected override Rune[] CharTable => new[] { - /// - public override string BodyName => "atascii"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Atari Standard Code for Information Interchange"; - /// - public override string HeaderName => "atascii"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + new Rune(0x2665), new Rune(0x251C), new Rune(0x1FB87), new Rune(0x2518), new Rune(0x2524), new Rune(0x2510), + new Rune(0x2571), new Rune(0x2572), - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => true; + // 0x08 + new Rune(0x25E2), new Rune(0x2597), new Rune(0x25E3), new Rune(0x259D), new Rune(0x2598), new Rune(0x1FB82), + new Rune(0x2582), new Rune(0x2596), - /// The ATASCII to Unicode character map. - protected override Rune[] CharTable => new[] - { - // 0x00 - new Rune(0x2665), new Rune(0x251C), new Rune(0x1FB87), new Rune(0x2518), new Rune(0x2524), new Rune(0x2510), - new Rune(0x2571), new Rune(0x2572), + // 0x10 + new Rune(0x2663), new Rune(0x250C), new Rune(0x2500), new Rune(0x253C), new Rune(0x25CF), new Rune(0x2584), + new Rune(0x258E), new Rune(0x252C), - // 0x08 - new Rune(0x25E2), new Rune(0x2597), new Rune(0x25E3), new Rune(0x259D), new Rune(0x2598), new Rune(0x1FB82), - new Rune(0x2582), new Rune(0x2596), + // 0x18 + new Rune(0x2534), new Rune(0x258C), new Rune(0x2514), new Rune(0x001B), new Rune(0x2191), new Rune(0x2193), + new Rune(0x2190), new Rune(0x2192), - // 0x10 - new Rune(0x2663), new Rune(0x250C), new Rune(0x2500), new Rune(0x253C), new Rune(0x25CF), new Rune(0x2584), - new Rune(0x258E), new Rune(0x252C), + // 0x20 + new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), + new Rune(0x0026), new Rune(0x0027), - // 0x18 - new Rune(0x2534), new Rune(0x258C), new Rune(0x2514), new Rune(0x001B), new Rune(0x2191), new Rune(0x2193), - new Rune(0x2190), new Rune(0x2192), + // 0x28 + new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), + new Rune(0x002E), new Rune(0x002F), - // 0x20 - new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), - new Rune(0x0026), new Rune(0x0027), + // 0x30 + new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), + new Rune(0x0036), new Rune(0x0037), - // 0x28 - new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), - new Rune(0x002E), new Rune(0x002F), + // 0x38 + new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), + new Rune(0x003E), new Rune(0x003F), - // 0x30 - new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), - new Rune(0x0036), new Rune(0x0037), + // 0x40 + new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), + new Rune(0x0046), new Rune(0x0047), - // 0x38 - new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), - new Rune(0x003E), new Rune(0x003F), + // 0x48 + new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), + new Rune(0x004E), new Rune(0x004F), - // 0x40 - new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), - new Rune(0x0046), new Rune(0x0047), + // 0x50 + new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), + new Rune(0x0056), new Rune(0x0057), - // 0x48 - new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), - new Rune(0x004E), new Rune(0x004F), + // 0x58 + new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), + new Rune(0x005E), new Rune(0x005F), - // 0x50 - new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), - new Rune(0x0056), new Rune(0x0057), + // 0x60 + new Rune(0x2666), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), + new Rune(0x0066), new Rune(0x0067), - // 0x58 - new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), - new Rune(0x005E), new Rune(0x005F), + // 0x68 + new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), + new Rune(0x006E), new Rune(0x006F), - // 0x60 - new Rune(0x2666), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), - new Rune(0x0066), new Rune(0x0067), + // 0x70 + new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), + new Rune(0x0076), new Rune(0x0077), - // 0x68 - new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), - new Rune(0x006E), new Rune(0x006F), + // 0x78 + new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x2660), new Rune(0x007C), new Rune(0x1F8B0), + new Rune(0x25C0), new Rune(0x25B6), - // 0x70 - new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), - new Rune(0x0076), new Rune(0x0077), + // 0x80 + new Rune(0x0000), new Rune(0x0000), new Rune(0x258A), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x78 - new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x2660), new Rune(0x007C), new Rune(0x1F8B0), - new Rune(0x25C0), new Rune(0x25B6), + // 0x88 + new Rune(0x25E4), new Rune(0x259B), new Rune(0x25E5), new Rune(0x2599), new Rune(0x259F), new Rune(0x2586), + new Rune(0x0000), new Rune(0x259C), - // 0x80 - new Rune(0x0000), new Rune(0x0000), new Rune(0x258A), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x90 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x25D8), new Rune(0x2580), + new Rune(0x0000), new Rune(0x0000), - // 0x88 - new Rune(0x25E4), new Rune(0x259B), new Rune(0x25E5), new Rune(0x2599), new Rune(0x259F), new Rune(0x2586), - new Rune(0x0000), new Rune(0x259C), + // 0x98 + new Rune(0x0000), new Rune(0x2590), new Rune(0x0000), new Rune(0x000D), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x90 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x25D8), new Rune(0x2580), - new Rune(0x0000), new Rune(0x0000), + // 0xA0 + new Rune(0x2588), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x98 - new Rune(0x0000), new Rune(0x2590), new Rune(0x0000), new Rune(0x000D), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xA8 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xA0 - new Rune(0x2588), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xB0 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xA8 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xB8 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xB0 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xC0 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xB8 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xC8 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xC0 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xD0 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xC8 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xD8 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xD0 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xE0 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xD8 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xE8 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xE0 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xF0 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xE8 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xF8 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0007), + new Rune(0x0000), new Rune(0x0000) + }; - // 0xF0 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), - - // 0xF8 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0007), - new Rune(0x0000), new Rune(0x0000) - }; - - /// Converts a Unicode character to an ATASCII character - /// ATASCII character. - /// Unicode character. - private protected override byte GetByte(Rune character) => character.Value switch - { - 0x2665 => 0x00, - 0x251C => 0x01, - 0x1FB87 => 0x02, - 0x2518 => 0x03, - 0x2524 => 0x04, - 0x2510 => 0x05, - 0x2571 => 0x06, - 0x2572 => 0x07, - 0x25E2 => 0x08, - 0x2597 => 0x09, - 0x25E3 => 0x0A, - 0x259D => 0x0B, - 0x2598 => 0x0C, - 0x1FB82 => 0x0D, - 0x2582 => 0x0E, - 0x2596 => 0x0F, - 0x2663 => 0x10, - 0x250C => 0x11, - 0x2500 => 0x12, - 0x253C => 0x13, - 0x25CF => 0x14, - 0x2584 => 0x15, - 0x258E => 0x16, - 0x252C => 0x17, - 0x2534 => 0x18, - 0x258C => 0x19, - 0x2514 => 0x1A, - 0x001B => 0x1B, - 0x2191 => 0x1C, - 0x2193 => 0x1D, - 0x2190 => 0x1E, - 0x2192 => 0x1F, - 0x0020 => 0x20, - 0x0021 => 0x21, - 0x0022 => 0x22, - 0x0023 => 0x23, - 0x0024 => 0x24, - 0x0025 => 0x25, - 0x0026 => 0x26, - 0x0027 => 0x27, - 0x0028 => 0x28, - 0x0029 => 0x29, - 0x002A => 0x2A, - 0x002B => 0x2B, - 0x002C => 0x2C, - 0x002D => 0x2D, - 0x002E => 0x2E, - 0x002F => 0x2F, - 0x0030 => 0x30, - 0x0031 => 0x31, - 0x0032 => 0x32, - 0x0033 => 0x33, - 0x0034 => 0x34, - 0x0035 => 0x35, - 0x0036 => 0x36, - 0x0037 => 0x37, - 0x0038 => 0x38, - 0x0039 => 0x39, - 0x003A => 0x3A, - 0x003B => 0x3B, - 0x003C => 0x3C, - 0x003D => 0x3D, - 0x003E => 0x3E, - 0x003F => 0x3F, - 0x0040 => 0x40, - 0x0041 => 0x41, - 0x0042 => 0x42, - 0x0043 => 0x43, - 0x0044 => 0x44, - 0x0045 => 0x45, - 0x0046 => 0x46, - 0x0047 => 0x47, - 0x0048 => 0x48, - 0x0049 => 0x49, - 0x004A => 0x4A, - 0x004B => 0x4B, - 0x004C => 0x4C, - 0x004D => 0x4D, - 0x004E => 0x4E, - 0x004F => 0x4F, - 0x0050 => 0x50, - 0x0051 => 0x51, - 0x0052 => 0x52, - 0x0053 => 0x53, - 0x0054 => 0x54, - 0x0055 => 0x55, - 0x0056 => 0x56, - 0x0057 => 0x57, - 0x0058 => 0x58, - 0x0059 => 0x59, - 0x005A => 0x5A, - 0x005B => 0x5B, - 0x005C => 0x5C, - 0x005D => 0x5D, - 0x005E => 0x5E, - 0x005F => 0x5F, - 0x2666 => 0x60, - 0x0061 => 0x61, - 0x0062 => 0x62, - 0x0063 => 0x63, - 0x0064 => 0x64, - 0x0065 => 0x65, - 0x0066 => 0x66, - 0x0067 => 0x67, - 0x0068 => 0x68, - 0x0069 => 0x69, - 0x006A => 0x6A, - 0x006B => 0x6B, - 0x006C => 0x6C, - 0x006D => 0x6D, - 0x006E => 0x6E, - 0x006F => 0x6F, - 0x0070 => 0x70, - 0x0071 => 0x71, - 0x0072 => 0x72, - 0x0073 => 0x73, - 0x0074 => 0x74, - 0x0075 => 0x75, - 0x0076 => 0x76, - 0x0077 => 0x77, - 0x0078 => 0x78, - 0x0079 => 0x79, - 0x007A => 0x7A, - 0x2660 => 0x7B, - 0x007C => 0x7C, - 0x1F8B0 => 0x7D, - 0x25C0 => 0x7E, - 0x25B6 => 0x7F, - 0x258A => 0x82, - 0x25E4 => 0x88, - 0x259B => 0x89, - 0x25E5 => 0x8A, - 0x2599 => 0x8B, - 0x259F => 0x8C, - 0x2586 => 0x8D, - 0x259C => 0x8F, - 0x25D8 => 0x94, - 0x2580 => 0x95, - 0x2590 => 0x99, - 0x000D => 0x9B, - 0x2588 => 0xA0, - 0x0007 => 0xFD, - _ => 0x3F - }; - } + /// Converts a Unicode character to an ATASCII character + /// ATASCII character. + /// Unicode character. + private protected override byte GetByte(Rune character) => character.Value switch + { + 0x2665 => 0x00, + 0x251C => 0x01, + 0x1FB87 => 0x02, + 0x2518 => 0x03, + 0x2524 => 0x04, + 0x2510 => 0x05, + 0x2571 => 0x06, + 0x2572 => 0x07, + 0x25E2 => 0x08, + 0x2597 => 0x09, + 0x25E3 => 0x0A, + 0x259D => 0x0B, + 0x2598 => 0x0C, + 0x1FB82 => 0x0D, + 0x2582 => 0x0E, + 0x2596 => 0x0F, + 0x2663 => 0x10, + 0x250C => 0x11, + 0x2500 => 0x12, + 0x253C => 0x13, + 0x25CF => 0x14, + 0x2584 => 0x15, + 0x258E => 0x16, + 0x252C => 0x17, + 0x2534 => 0x18, + 0x258C => 0x19, + 0x2514 => 0x1A, + 0x001B => 0x1B, + 0x2191 => 0x1C, + 0x2193 => 0x1D, + 0x2190 => 0x1E, + 0x2192 => 0x1F, + 0x0020 => 0x20, + 0x0021 => 0x21, + 0x0022 => 0x22, + 0x0023 => 0x23, + 0x0024 => 0x24, + 0x0025 => 0x25, + 0x0026 => 0x26, + 0x0027 => 0x27, + 0x0028 => 0x28, + 0x0029 => 0x29, + 0x002A => 0x2A, + 0x002B => 0x2B, + 0x002C => 0x2C, + 0x002D => 0x2D, + 0x002E => 0x2E, + 0x002F => 0x2F, + 0x0030 => 0x30, + 0x0031 => 0x31, + 0x0032 => 0x32, + 0x0033 => 0x33, + 0x0034 => 0x34, + 0x0035 => 0x35, + 0x0036 => 0x36, + 0x0037 => 0x37, + 0x0038 => 0x38, + 0x0039 => 0x39, + 0x003A => 0x3A, + 0x003B => 0x3B, + 0x003C => 0x3C, + 0x003D => 0x3D, + 0x003E => 0x3E, + 0x003F => 0x3F, + 0x0040 => 0x40, + 0x0041 => 0x41, + 0x0042 => 0x42, + 0x0043 => 0x43, + 0x0044 => 0x44, + 0x0045 => 0x45, + 0x0046 => 0x46, + 0x0047 => 0x47, + 0x0048 => 0x48, + 0x0049 => 0x49, + 0x004A => 0x4A, + 0x004B => 0x4B, + 0x004C => 0x4C, + 0x004D => 0x4D, + 0x004E => 0x4E, + 0x004F => 0x4F, + 0x0050 => 0x50, + 0x0051 => 0x51, + 0x0052 => 0x52, + 0x0053 => 0x53, + 0x0054 => 0x54, + 0x0055 => 0x55, + 0x0056 => 0x56, + 0x0057 => 0x57, + 0x0058 => 0x58, + 0x0059 => 0x59, + 0x005A => 0x5A, + 0x005B => 0x5B, + 0x005C => 0x5C, + 0x005D => 0x5D, + 0x005E => 0x5E, + 0x005F => 0x5F, + 0x2666 => 0x60, + 0x0061 => 0x61, + 0x0062 => 0x62, + 0x0063 => 0x63, + 0x0064 => 0x64, + 0x0065 => 0x65, + 0x0066 => 0x66, + 0x0067 => 0x67, + 0x0068 => 0x68, + 0x0069 => 0x69, + 0x006A => 0x6A, + 0x006B => 0x6B, + 0x006C => 0x6C, + 0x006D => 0x6D, + 0x006E => 0x6E, + 0x006F => 0x6F, + 0x0070 => 0x70, + 0x0071 => 0x71, + 0x0072 => 0x72, + 0x0073 => 0x73, + 0x0074 => 0x74, + 0x0075 => 0x75, + 0x0076 => 0x76, + 0x0077 => 0x77, + 0x0078 => 0x78, + 0x0079 => 0x79, + 0x007A => 0x7A, + 0x2660 => 0x7B, + 0x007C => 0x7C, + 0x1F8B0 => 0x7D, + 0x25C0 => 0x7E, + 0x25B6 => 0x7F, + 0x258A => 0x82, + 0x25E4 => 0x88, + 0x259B => 0x89, + 0x25E5 => 0x8A, + 0x2599 => 0x8B, + 0x259F => 0x8C, + 0x2586 => 0x8D, + 0x259C => 0x8F, + 0x25D8 => 0x94, + 0x2580 => 0x95, + 0x2590 => 0x99, + 0x000D => 0x9B, + 0x2588 => 0xA0, + 0x0007 => 0xFD, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/Apple2.cs b/Claunia.Encoding/Apple2.cs index f2f56ab..4a8f6ec 100644 --- a/Claunia.Encoding/Apple2.cs +++ b/Claunia.Encoding/Apple2.cs @@ -24,207 +24,206 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Apple II character encoding of Unicode characters. +public sealed class Apple2 : SingleByteEncoding { - /// Represents an Apple II character encoding of Unicode characters. - public sealed class Apple2 : SingleByteEncoding + /// + public override string BodyName => "apple2"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Western European (Apple II)"; + /// + public override string HeaderName => "apple2"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => true; + + /// The Apple II to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "apple2"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Western European (Apple II)"; - /// - public override string HeaderName => "apple2"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - /// The Apple II to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x10 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x08 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x18 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x10 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x60 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x70 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x68 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x78 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x70 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x80 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x78 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x88 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x80 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0x90 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x88 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0x98 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x90 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xA0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x98 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xA8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xA0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xB0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xA8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xB8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xB0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xC0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xB8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xC8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xC0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xD0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xC8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xD8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xD0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xE0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xD8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xE8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xE0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xF0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xE8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xF8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' + }; - // 0xF0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - - // 0xF8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' - }; - - /// Converts a Unicode character to an Apple II character - /// Apple II character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Apple II character + /// Apple II character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/Apple2c.cs b/Claunia.Encoding/Apple2c.cs index fd4e740..241e738 100644 --- a/Claunia.Encoding/Apple2c.cs +++ b/Claunia.Encoding/Apple2c.cs @@ -26,335 +26,334 @@ using System.Text; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Apple IIc character encoding of Unicode characters. +public sealed class Apple2c : SingleByteEncodingWithRunes { - /// Represents an Apple IIc character encoding of Unicode characters. - public sealed class Apple2c : SingleByteEncodingWithRunes + /// + public override string BodyName => "apple2c"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Western European (Apple IIc)"; + /// + public override string HeaderName => "apple2c"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Apple IIc to Unicode character map. Inverted screen characters are mapped to normal characters. + protected override Rune[] CharTable => new[] { - /// - public override string BodyName => "apple2c"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Western European (Apple IIc)"; - /// - public override string HeaderName => "apple2c"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + new Rune(0x0000), new Rune(0x0001), new Rune(0x0002), new Rune(0x0003), new Rune(0x0004), new Rune(0x0005), + new Rune(0x0006), new Rune(0x0007), - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + new Rune(0x0008), new Rune(0x0009), new Rune(0x000A), new Rune(0x000B), new Rune(0x000C), new Rune(0x000D), + new Rune(0x000E), new Rune(0x000F), - /// The Apple IIc to Unicode character map. Inverted screen characters are mapped to normal characters. - protected override Rune[] CharTable => new[] - { - // 0x00 - new Rune(0x0000), new Rune(0x0001), new Rune(0x0002), new Rune(0x0003), new Rune(0x0004), new Rune(0x0005), - new Rune(0x0006), new Rune(0x0007), + // 0x10 + new Rune(0x0010), new Rune(0x0011), new Rune(0x0012), new Rune(0x0013), new Rune(0x0014), new Rune(0x0015), + new Rune(0x0016), new Rune(0x0017), - // 0x08 - new Rune(0x0008), new Rune(0x0009), new Rune(0x000A), new Rune(0x000B), new Rune(0x000C), new Rune(0x000D), - new Rune(0x000E), new Rune(0x000F), + // 0x18 + new Rune(0x0018), new Rune(0x0019), new Rune(0x001A), new Rune(0x001B), new Rune(0x001C), new Rune(0x001D), + new Rune(0x001E), new Rune(0x001F), - // 0x10 - new Rune(0x0010), new Rune(0x0011), new Rune(0x0012), new Rune(0x0013), new Rune(0x0014), new Rune(0x0015), - new Rune(0x0016), new Rune(0x0017), + // 0x20 + new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), + new Rune(0x0026), new Rune(0x0027), - // 0x18 - new Rune(0x0018), new Rune(0x0019), new Rune(0x001A), new Rune(0x001B), new Rune(0x001C), new Rune(0x001D), - new Rune(0x001E), new Rune(0x001F), + // 0x28 + new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), + new Rune(0x002E), new Rune(0x002F), - // 0x20 - new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), - new Rune(0x0026), new Rune(0x0027), + // 0x30 + new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), + new Rune(0x0036), new Rune(0x0037), - // 0x28 - new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), - new Rune(0x002E), new Rune(0x002F), + // 0x38 + new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), + new Rune(0x003E), new Rune(0x003F), - // 0x30 - new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), - new Rune(0x0036), new Rune(0x0037), + // 0x40 + new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), + new Rune(0x0046), new Rune(0x0047), - // 0x38 - new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), - new Rune(0x003E), new Rune(0x003F), + // 0x48 + new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), + new Rune(0x004E), new Rune(0x004F), - // 0x40 - new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), - new Rune(0x0046), new Rune(0x0047), + // 0x50 + new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), + new Rune(0x0056), new Rune(0x0057), - // 0x48 - new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), - new Rune(0x004E), new Rune(0x004F), + // 0x58 + new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x00A3), new Rune(0x005D), + new Rune(0x005E), new Rune(0x005F), - // 0x50 - new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), - new Rune(0x0056), new Rune(0x0057), + // 0x60 + new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), + new Rune(0x0066), new Rune(0x0067), - // 0x58 - new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x00A3), new Rune(0x005D), - new Rune(0x005E), new Rune(0x005F), + // 0x68 + new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), + new Rune(0x006E), new Rune(0x006F), - // 0x60 - new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), - new Rune(0x0066), new Rune(0x0067), + // 0x70 + new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), + new Rune(0x0076), new Rune(0x0077), - // 0x68 - new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), - new Rune(0x006E), new Rune(0x006F), + // 0x78 + new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), + new Rune(0x007E), new Rune(0x007F), - // 0x70 - new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), - new Rune(0x0076), new Rune(0x0077), + // 0x80 + new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), + new Rune(0x0046), new Rune(0x0047), - // 0x78 - new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), - new Rune(0x007E), new Rune(0x007F), + // 0x88 + new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), + new Rune(0x004E), new Rune(0x004F), - // 0x80 - new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), - new Rune(0x0046), new Rune(0x0047), + // 0x90 + new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), + new Rune(0x0056), new Rune(0x0057), - // 0x88 - new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), - new Rune(0x004E), new Rune(0x004F), + // 0x98 + new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x00A3), new Rune(0x005D), + new Rune(0x005E), new Rune(0x0020), - // 0x90 - new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), - new Rune(0x0056), new Rune(0x0057), + // 0xA0 + new Rune(0x2588), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), + new Rune(0x0026), new Rune(0x0027), - // 0x98 - new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x00A3), new Rune(0x005D), - new Rune(0x005E), new Rune(0x0020), + // 0xA8 + new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), + new Rune(0x002E), new Rune(0x002F), - // 0xA0 - new Rune(0x2588), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), - new Rune(0x0026), new Rune(0x0027), + // 0xB0 + new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), + new Rune(0x0036), new Rune(0x0037), - // 0xA8 - new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), - new Rune(0x002E), new Rune(0x002F), + // 0xB8 + new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), + new Rune(0x0036), new Rune(0x0037), - // 0xB0 - new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), - new Rune(0x0036), new Rune(0x0037), + // 0xC0 + new Rune(0xF8FF), new Rune(0x0000), new Rune(0x1FBB0), new Rune(0x231B), new Rune(0x2713), + new Rune(0x1FBB1), new Rune(0x1FBB2), new Rune(0x1FBB3), - // 0xB8 - new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), - new Rune(0x0036), new Rune(0x0037), + // 0xC8 + new Rune(0x2190), new Rune(0x2026), new Rune(0x2193), new Rune(0x2191), new Rune(0x1FB76), new Rune(0x21B5), + new Rune(0x2589), new Rune(0x1FBB5), - // 0xC0 - new Rune(0xF8FF), new Rune(0x0000), new Rune(0x1FBB0), new Rune(0x231B), new Rune(0x2713), - new Rune(0x1FBB1), new Rune(0x1FBB2), new Rune(0x1FBB3), + // 0xD0 + new Rune(0x1FBB6), new Rune(0x1FBB7), new Rune(0x1FBB8), new Rune(0x2500), new Rune(0x1FB7C), + new Rune(0x2192), new Rune(0x2592), new Rune(0x1FB90), - // 0xC8 - new Rune(0x2190), new Rune(0x2026), new Rune(0x2193), new Rune(0x2191), new Rune(0x1FB76), new Rune(0x21B5), - new Rune(0x2589), new Rune(0x1FBB5), + // 0xD8 + new Rune(0x1FBB9), new Rune(0x1FBBA), new Rune(0x2595), new Rune(0x25c6), new Rune(0x1FB80), + new Rune(0x1FBBB), new Rune(0x1FBBC), new Rune(0x258F), - // 0xD0 - new Rune(0x1FBB6), new Rune(0x1FBB7), new Rune(0x1FBB8), new Rune(0x2500), new Rune(0x1FB7C), - new Rune(0x2192), new Rune(0x2592), new Rune(0x1FB90), + // 0xE0 + new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), + new Rune(0x0066), new Rune(0x0067), - // 0xD8 - new Rune(0x1FBB9), new Rune(0x1FBBA), new Rune(0x2595), new Rune(0x25c6), new Rune(0x1FB80), - new Rune(0x1FBBB), new Rune(0x1FBBC), new Rune(0x258F), + // 0xE8 + new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), + new Rune(0x006E), new Rune(0x006F), - // 0xE0 - new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), - new Rune(0x0066), new Rune(0x0067), + // 0xF0 + new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), + new Rune(0x0076), new Rune(0x0077), - // 0xE8 - new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), - new Rune(0x006E), new Rune(0x006F), + // 0xF8 + new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), + new Rune(0x007E), new Rune(0x007F) + }; - // 0xF0 - new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), - new Rune(0x0076), new Rune(0x0077), - - // 0xF8 - new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), - new Rune(0x007E), new Rune(0x007F) - }; - - /// Converts a Unicode character to an Apple IIc character - /// Apple IIc character. - /// Unicode character. - private protected override byte GetByte(Rune character) => character.Value switch - { - 0x0000 => 0x00, - 0x0001 => 0x01, - 0x0002 => 0x02, - 0x0003 => 0x03, - 0x0004 => 0x04, - 0x0005 => 0x05, - 0x0006 => 0x06, - 0x0007 => 0x07, - 0x0008 => 0x08, - 0x0009 => 0x09, - 0x000A => 0x0A, - 0x000B => 0x0B, - 0x000C => 0x0C, - 0x000D => 0x0D, - 0x000E => 0x0E, - 0x000F => 0x0F, - 0x0010 => 0x10, - 0x0011 => 0x11, - 0x0012 => 0x12, - 0x0013 => 0x13, - 0x0014 => 0x14, - 0x0015 => 0x15, - 0x0016 => 0x16, - 0x0017 => 0x17, - 0x0018 => 0x18, - 0x0019 => 0x19, - 0x001A => 0x1A, - 0x001B => 0x1B, - 0x001C => 0x1C, - 0x001D => 0x1D, - 0x001E => 0x1E, - 0x001F => 0x1F, - 0x0020 => 0x20, - 0x0021 => 0x21, - 0x0022 => 0x22, - 0x0023 => 0x23, - 0x0024 => 0x24, - 0x0025 => 0x25, - 0x0026 => 0x26, - 0x0027 => 0x27, - 0x0028 => 0x28, - 0x0029 => 0x29, - 0x002A => 0x2A, - 0x002B => 0x2B, - 0x002C => 0x2C, - 0x002D => 0x2D, - 0x002E => 0x2E, - 0x002F => 0x2F, - 0x0030 => 0x30, - 0x0031 => 0x31, - 0x0032 => 0x32, - 0x0033 => 0x33, - 0x0034 => 0x34, - 0x0035 => 0x35, - 0x0036 => 0x36, - 0x0037 => 0x37, - 0x0038 => 0x38, - 0x0039 => 0x39, - 0x003A => 0x3A, - 0x003B => 0x3B, - 0x003C => 0x3C, - 0x003D => 0x3D, - 0x003E => 0x3E, - 0x003F => 0x3F, - 0x0040 => 0x40, - 0x0041 => 0x41, - 0x0042 => 0x42, - 0x0043 => 0x43, - 0x0044 => 0x44, - 0x0045 => 0x45, - 0x0046 => 0x46, - 0x0047 => 0x47, - 0x0048 => 0x48, - 0x0049 => 0x49, - 0x004A => 0x4A, - 0x004B => 0x4B, - 0x004C => 0x4C, - 0x004D => 0x4D, - 0x004E => 0x4E, - 0x004F => 0x4F, - 0x0050 => 0x50, - 0x0051 => 0x51, - 0x0052 => 0x52, - 0x0053 => 0x53, - 0x0054 => 0x54, - 0x0055 => 0x55, - 0x0056 => 0x56, - 0x0057 => 0x57, - 0x0058 => 0x58, - 0x0059 => 0x59, - 0x005A => 0x5A, - 0x005B => 0x5B, - 0x00A3 => 0x5C, - 0x005D => 0x5D, - 0x005E => 0x5E, - 0x005F => 0x5F, - 0x0060 => 0x60, - 0x0061 => 0x61, - 0x0062 => 0x62, - 0x0063 => 0x63, - 0x0064 => 0x64, - 0x0065 => 0x65, - 0x0066 => 0x66, - 0x0067 => 0x67, - 0x0068 => 0x68, - 0x0069 => 0x69, - 0x006A => 0x6A, - 0x006B => 0x6B, - 0x006C => 0x6C, - 0x006D => 0x6D, - 0x006E => 0x6E, - 0x006F => 0x6F, - 0x0070 => 0x70, - 0x0071 => 0x71, - 0x0072 => 0x72, - 0x0073 => 0x73, - 0x0074 => 0x74, - 0x0075 => 0x75, - 0x0076 => 0x76, - 0x0077 => 0x77, - 0x0078 => 0x78, - 0x0079 => 0x79, - 0x007A => 0x7A, - 0x007B => 0x7B, - 0x007C => 0x7C, - 0x007D => 0x7D, - 0x007E => 0x7E, - 0x007F => 0x7F, - 0x2588 => 0xA0, - 0xF8FF => 0xC0, - 0x1FBB0 => 0xC2, - 0x231B => 0xC3, - 0x2713 => 0xC4, - 0x1FBB1 => 0xC5, - 0x1FBB2 => 0xC6, - 0x1FBB3 => 0xC7, - 0x2190 => 0xC8, - 0x2026 => 0xC9, - 0x2193 => 0xCA, - 0x2191 => 0xCB, - 0x1FB76 => 0xCC, - 0x21B5 => 0xCD, - 0x2589 => 0xCE, - 0x1FBB5 => 0xCF, - 0x1FBB6 => 0xD0, - 0x1FBB7 => 0xD1, - 0x1FBB8 => 0xD2, - 0x2500 => 0xD3, - 0x1FB7C => 0xD4, - 0x2192 => 0xD5, - 0x2592 => 0xD6, - 0x1FB90 => 0xD7, - 0x1FBB9 => 0xD8, - 0x1FBBA => 0xD9, - 0x2595 => 0xDA, - 0x25C6 => 0xDB, - 0x1FB80 => 0xDC, - 0x1FBBB => 0xDD, - 0x1FBBC => 0xDE, - 0x258F => 0xDF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Apple IIc character + /// Apple IIc character. + /// Unicode character. + private protected override byte GetByte(Rune character) => character.Value switch + { + 0x0000 => 0x00, + 0x0001 => 0x01, + 0x0002 => 0x02, + 0x0003 => 0x03, + 0x0004 => 0x04, + 0x0005 => 0x05, + 0x0006 => 0x06, + 0x0007 => 0x07, + 0x0008 => 0x08, + 0x0009 => 0x09, + 0x000A => 0x0A, + 0x000B => 0x0B, + 0x000C => 0x0C, + 0x000D => 0x0D, + 0x000E => 0x0E, + 0x000F => 0x0F, + 0x0010 => 0x10, + 0x0011 => 0x11, + 0x0012 => 0x12, + 0x0013 => 0x13, + 0x0014 => 0x14, + 0x0015 => 0x15, + 0x0016 => 0x16, + 0x0017 => 0x17, + 0x0018 => 0x18, + 0x0019 => 0x19, + 0x001A => 0x1A, + 0x001B => 0x1B, + 0x001C => 0x1C, + 0x001D => 0x1D, + 0x001E => 0x1E, + 0x001F => 0x1F, + 0x0020 => 0x20, + 0x0021 => 0x21, + 0x0022 => 0x22, + 0x0023 => 0x23, + 0x0024 => 0x24, + 0x0025 => 0x25, + 0x0026 => 0x26, + 0x0027 => 0x27, + 0x0028 => 0x28, + 0x0029 => 0x29, + 0x002A => 0x2A, + 0x002B => 0x2B, + 0x002C => 0x2C, + 0x002D => 0x2D, + 0x002E => 0x2E, + 0x002F => 0x2F, + 0x0030 => 0x30, + 0x0031 => 0x31, + 0x0032 => 0x32, + 0x0033 => 0x33, + 0x0034 => 0x34, + 0x0035 => 0x35, + 0x0036 => 0x36, + 0x0037 => 0x37, + 0x0038 => 0x38, + 0x0039 => 0x39, + 0x003A => 0x3A, + 0x003B => 0x3B, + 0x003C => 0x3C, + 0x003D => 0x3D, + 0x003E => 0x3E, + 0x003F => 0x3F, + 0x0040 => 0x40, + 0x0041 => 0x41, + 0x0042 => 0x42, + 0x0043 => 0x43, + 0x0044 => 0x44, + 0x0045 => 0x45, + 0x0046 => 0x46, + 0x0047 => 0x47, + 0x0048 => 0x48, + 0x0049 => 0x49, + 0x004A => 0x4A, + 0x004B => 0x4B, + 0x004C => 0x4C, + 0x004D => 0x4D, + 0x004E => 0x4E, + 0x004F => 0x4F, + 0x0050 => 0x50, + 0x0051 => 0x51, + 0x0052 => 0x52, + 0x0053 => 0x53, + 0x0054 => 0x54, + 0x0055 => 0x55, + 0x0056 => 0x56, + 0x0057 => 0x57, + 0x0058 => 0x58, + 0x0059 => 0x59, + 0x005A => 0x5A, + 0x005B => 0x5B, + 0x00A3 => 0x5C, + 0x005D => 0x5D, + 0x005E => 0x5E, + 0x005F => 0x5F, + 0x0060 => 0x60, + 0x0061 => 0x61, + 0x0062 => 0x62, + 0x0063 => 0x63, + 0x0064 => 0x64, + 0x0065 => 0x65, + 0x0066 => 0x66, + 0x0067 => 0x67, + 0x0068 => 0x68, + 0x0069 => 0x69, + 0x006A => 0x6A, + 0x006B => 0x6B, + 0x006C => 0x6C, + 0x006D => 0x6D, + 0x006E => 0x6E, + 0x006F => 0x6F, + 0x0070 => 0x70, + 0x0071 => 0x71, + 0x0072 => 0x72, + 0x0073 => 0x73, + 0x0074 => 0x74, + 0x0075 => 0x75, + 0x0076 => 0x76, + 0x0077 => 0x77, + 0x0078 => 0x78, + 0x0079 => 0x79, + 0x007A => 0x7A, + 0x007B => 0x7B, + 0x007C => 0x7C, + 0x007D => 0x7D, + 0x007E => 0x7E, + 0x007F => 0x7F, + 0x2588 => 0xA0, + 0xF8FF => 0xC0, + 0x1FBB0 => 0xC2, + 0x231B => 0xC3, + 0x2713 => 0xC4, + 0x1FBB1 => 0xC5, + 0x1FBB2 => 0xC6, + 0x1FBB3 => 0xC7, + 0x2190 => 0xC8, + 0x2026 => 0xC9, + 0x2193 => 0xCA, + 0x2191 => 0xCB, + 0x1FB76 => 0xCC, + 0x21B5 => 0xCD, + 0x2589 => 0xCE, + 0x1FBB5 => 0xCF, + 0x1FBB6 => 0xD0, + 0x1FBB7 => 0xD1, + 0x1FBB8 => 0xD2, + 0x2500 => 0xD3, + 0x1FB7C => 0xD4, + 0x2192 => 0xD5, + 0x2592 => 0xD6, + 0x1FB90 => 0xD7, + 0x1FBB9 => 0xD8, + 0x1FBBA => 0xD9, + 0x2595 => 0xDA, + 0x25C6 => 0xDB, + 0x1FB80 => 0xDC, + 0x1FBBB => 0xDD, + 0x1FBBC => 0xDE, + 0x258F => 0xDF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/Apple2e.cs b/Claunia.Encoding/Apple2e.cs index 7e3f8f0..6592674 100644 --- a/Claunia.Encoding/Apple2e.cs +++ b/Claunia.Encoding/Apple2e.cs @@ -24,268 +24,267 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Apple IIe character encoding of Unicode characters. +public class Apple2e : SingleByteEncoding { - /// Represents an Apple IIe character encoding of Unicode characters. - public class Apple2e : SingleByteEncoding + /// + public override string BodyName => "apple2e"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Western European (Apple IIe)"; + /// + public override string HeaderName => "apple2e"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Apple IIe to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "apple2e"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Western European (Apple IIe)"; - /// - public override string HeaderName => "apple2e"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - /// The Apple IIe to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x10 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x08 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x18 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x10 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x20 + '\u0040', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x18 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x28 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x20 - '\u0040', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x30 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x28 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x38 + '\u0078', '\u0079', '\u007A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x30 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x40 + '\u00A0', '\u2575', '\u2574', '\u2577', '\u2576', '\u2518', '\u2510', '\u250C', - // 0x38 - '\u0078', '\u0079', '\u007A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x48 + '\u2514', '\u2500', '\u2502', '\u2534', '\u2524', '\u252C', '\u251C', '\u253C', - // 0x40 - '\u00A0', '\u2575', '\u2574', '\u2577', '\u2576', '\u2518', '\u2510', '\u250C', + // 0x50 + '\u25E4', '\u25E5', '\u2592', '\u2598', '\u259D', '\u2580', '\u2596', '\u2597', - // 0x48 - '\u2514', '\u2500', '\u2502', '\u2534', '\u2524', '\u252C', '\u251C', '\u253C', + // 0x58 + '\u259A', '\u258C', '\u0000', '\u0000', '\u2190', '\u2191', '\u2192', '\u2193', - // 0x50 - '\u25E4', '\u25E5', '\u2592', '\u2598', '\u259D', '\u2580', '\u2596', '\u2597', + // 0x60 + '\u03C0', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x58 - '\u259A', '\u258C', '\u0000', '\u0000', '\u2190', '\u2191', '\u2192', '\u2193', + // 0x68 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x60 - '\u03C0', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x70 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x68 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x78 + '\u0058', '\u0059', '\u005A', '\u007B', '\u007C', '\u007D', '\u007E', '\u0000', - // 0x70 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x80 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x78 - '\u0058', '\u0059', '\u005A', '\u007B', '\u007C', '\u007D', '\u007E', '\u0000', + // 0x88 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x80 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0x90 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x88 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0x98 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x90 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xA0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x98 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xA8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xA0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xB0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xA8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xB8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xB0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xC0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xB8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xC8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xC0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xD0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xC8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xD8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xD0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xE0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xD8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xE8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xE0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xF0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xE8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xF8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' + }; - // 0xF0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - - // 0xF8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' - }; - - /// Converts a Unicode character to an Apple IIe character - /// Apple IIe character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0020' => 0x00, - '\u0021' => 0x01, - '\u0022' => 0x02, - '\u0023' => 0x03, - '\u0024' => 0x04, - '\u0025' => 0x05, - '\u0026' => 0x06, - '\u0027' => 0x07, - '\u0028' => 0x08, - '\u0029' => 0x09, - '\u002A' => 0x0A, - '\u002B' => 0x0B, - '\u002C' => 0x0C, - '\u002D' => 0x0D, - '\u002E' => 0x0E, - '\u002F' => 0x0F, - '\u0030' => 0x10, - '\u0031' => 0x11, - '\u0032' => 0x12, - '\u0033' => 0x13, - '\u0034' => 0x14, - '\u0035' => 0x15, - '\u0036' => 0x16, - '\u0037' => 0x17, - '\u0038' => 0x18, - '\u0039' => 0x19, - '\u003A' => 0x1A, - '\u003B' => 0x1B, - '\u003C' => 0x1C, - '\u003D' => 0x1D, - '\u003E' => 0x1E, - '\u003F' => 0x1F, - '\u0040' => 0x20, - '\u0061' => 0x21, - '\u0062' => 0x22, - '\u0063' => 0x23, - '\u0064' => 0x24, - '\u0065' => 0x25, - '\u0066' => 0x26, - '\u0067' => 0x27, - '\u0068' => 0x28, - '\u0069' => 0x29, - '\u006A' => 0x2A, - '\u006B' => 0x2B, - '\u006C' => 0x2C, - '\u006D' => 0x2D, - '\u006E' => 0x2E, - '\u006F' => 0x2F, - '\u0070' => 0x30, - '\u0071' => 0x31, - '\u0072' => 0x32, - '\u0073' => 0x33, - '\u0074' => 0x34, - '\u0075' => 0x35, - '\u0076' => 0x36, - '\u0077' => 0x37, - '\u0078' => 0x38, - '\u0079' => 0x39, - '\u007A' => 0x3A, - '\u005B' => 0x3B, - '\u005C' => 0x3C, - '\u005D' => 0x3D, - '\u005E' => 0x3E, - '\u005F' => 0x3F, - '\u00A0' => 0x40, - '\u2575' => 0x41, - '\u2574' => 0x42, - '\u2577' => 0x43, - '\u2576' => 0x44, - '\u2518' => 0x45, - '\u2510' => 0x46, - '\u250C' => 0x47, - '\u2514' => 0x48, - '\u2500' => 0x49, - '\u2502' => 0x4A, - '\u2534' => 0x4B, - '\u2524' => 0x4C, - '\u252C' => 0x4D, - '\u251C' => 0x4E, - '\u253C' => 0x4F, - '\u25E4' => 0x50, - '\u25E5' => 0x51, - '\u2592' => 0x52, - '\u2598' => 0x53, - '\u259D' => 0x54, - '\u2580' => 0x55, - '\u2596' => 0x56, - '\u2597' => 0x57, - '\u259A' => 0x58, - '\u258C' => 0x59, - '\u2190' => 0x5C, - '\u2191' => 0x5D, - '\u2192' => 0x5E, - '\u2193' => 0x5F, - '\u03C0' => 0x60, - '\u0041' => 0x61, - '\u0042' => 0x62, - '\u0043' => 0x63, - '\u0044' => 0x64, - '\u0045' => 0x65, - '\u0046' => 0x66, - '\u0047' => 0x67, - '\u0048' => 0x68, - '\u0049' => 0x69, - '\u004A' => 0x6A, - '\u004B' => 0x6B, - '\u004C' => 0x6C, - '\u004D' => 0x6D, - '\u004E' => 0x6E, - '\u004F' => 0x6F, - '\u0050' => 0x70, - '\u0051' => 0x71, - '\u0052' => 0x72, - '\u0053' => 0x73, - '\u0054' => 0x74, - '\u0055' => 0x75, - '\u0056' => 0x76, - '\u0057' => 0x77, - '\u0058' => 0x78, - '\u0059' => 0x79, - '\u005A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Apple IIe character + /// Apple IIe character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0020' => 0x00, + '\u0021' => 0x01, + '\u0022' => 0x02, + '\u0023' => 0x03, + '\u0024' => 0x04, + '\u0025' => 0x05, + '\u0026' => 0x06, + '\u0027' => 0x07, + '\u0028' => 0x08, + '\u0029' => 0x09, + '\u002A' => 0x0A, + '\u002B' => 0x0B, + '\u002C' => 0x0C, + '\u002D' => 0x0D, + '\u002E' => 0x0E, + '\u002F' => 0x0F, + '\u0030' => 0x10, + '\u0031' => 0x11, + '\u0032' => 0x12, + '\u0033' => 0x13, + '\u0034' => 0x14, + '\u0035' => 0x15, + '\u0036' => 0x16, + '\u0037' => 0x17, + '\u0038' => 0x18, + '\u0039' => 0x19, + '\u003A' => 0x1A, + '\u003B' => 0x1B, + '\u003C' => 0x1C, + '\u003D' => 0x1D, + '\u003E' => 0x1E, + '\u003F' => 0x1F, + '\u0040' => 0x20, + '\u0061' => 0x21, + '\u0062' => 0x22, + '\u0063' => 0x23, + '\u0064' => 0x24, + '\u0065' => 0x25, + '\u0066' => 0x26, + '\u0067' => 0x27, + '\u0068' => 0x28, + '\u0069' => 0x29, + '\u006A' => 0x2A, + '\u006B' => 0x2B, + '\u006C' => 0x2C, + '\u006D' => 0x2D, + '\u006E' => 0x2E, + '\u006F' => 0x2F, + '\u0070' => 0x30, + '\u0071' => 0x31, + '\u0072' => 0x32, + '\u0073' => 0x33, + '\u0074' => 0x34, + '\u0075' => 0x35, + '\u0076' => 0x36, + '\u0077' => 0x37, + '\u0078' => 0x38, + '\u0079' => 0x39, + '\u007A' => 0x3A, + '\u005B' => 0x3B, + '\u005C' => 0x3C, + '\u005D' => 0x3D, + '\u005E' => 0x3E, + '\u005F' => 0x3F, + '\u00A0' => 0x40, + '\u2575' => 0x41, + '\u2574' => 0x42, + '\u2577' => 0x43, + '\u2576' => 0x44, + '\u2518' => 0x45, + '\u2510' => 0x46, + '\u250C' => 0x47, + '\u2514' => 0x48, + '\u2500' => 0x49, + '\u2502' => 0x4A, + '\u2534' => 0x4B, + '\u2524' => 0x4C, + '\u252C' => 0x4D, + '\u251C' => 0x4E, + '\u253C' => 0x4F, + '\u25E4' => 0x50, + '\u25E5' => 0x51, + '\u2592' => 0x52, + '\u2598' => 0x53, + '\u259D' => 0x54, + '\u2580' => 0x55, + '\u2596' => 0x56, + '\u2597' => 0x57, + '\u259A' => 0x58, + '\u258C' => 0x59, + '\u2190' => 0x5C, + '\u2191' => 0x5D, + '\u2192' => 0x5E, + '\u2193' => 0x5F, + '\u03C0' => 0x60, + '\u0041' => 0x61, + '\u0042' => 0x62, + '\u0043' => 0x63, + '\u0044' => 0x64, + '\u0045' => 0x65, + '\u0046' => 0x66, + '\u0047' => 0x67, + '\u0048' => 0x68, + '\u0049' => 0x69, + '\u004A' => 0x6A, + '\u004B' => 0x6B, + '\u004C' => 0x6C, + '\u004D' => 0x6D, + '\u004E' => 0x6E, + '\u004F' => 0x6F, + '\u0050' => 0x70, + '\u0051' => 0x71, + '\u0052' => 0x72, + '\u0053' => 0x73, + '\u0054' => 0x74, + '\u0055' => 0x75, + '\u0056' => 0x76, + '\u0057' => 0x77, + '\u0058' => 0x78, + '\u0059' => 0x79, + '\u005A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/Apple2gs.cs b/Claunia.Encoding/Apple2gs.cs index eeddc12..8be7797 100644 --- a/Claunia.Encoding/Apple2gs.cs +++ b/Claunia.Encoding/Apple2gs.cs @@ -26,302 +26,301 @@ using System.Text; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Apple IIgs character encoding of Unicode characters. +public class Apple2gs : SingleByteEncodingWithRunes { - /// Represents an Apple IIgs character encoding of Unicode characters. - public class Apple2gs : SingleByteEncodingWithRunes + /// + public override string BodyName => "apple2gs"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Western European (Apple IIgs)"; + /// + public override string HeaderName => "apple2gs"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Apple IIgs to Unicode character map. Inverted screen characters are mapped to normal characters. + protected override Rune[] CharTable => new[] { - /// - public override string BodyName => "apple2gs"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Western European (Apple IIgs)"; - /// - public override string HeaderName => "apple2gs"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), + new Rune(0x0046), new Rune(0x0047), - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), + new Rune(0x004E), new Rune(0x004F), - /// The Apple IIgs to Unicode character map. Inverted screen characters are mapped to normal characters. - protected override Rune[] CharTable => new[] - { - // 0x00 - new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), - new Rune(0x0046), new Rune(0x0047), + // 0x10 + new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), + new Rune(0x0056), new Rune(0x0057), - // 0x08 - new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), - new Rune(0x004E), new Rune(0x004F), + // 0x18 + new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), + new Rune(0x005E), new Rune(0x0020), - // 0x10 - new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), - new Rune(0x0056), new Rune(0x0057), + // 0x20 + new Rune(0x2588), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), + new Rune(0x0026), new Rune(0x0027), - // 0x18 - new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), - new Rune(0x005E), new Rune(0x0020), + // 0x28 + new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), + new Rune(0x002E), new Rune(0x002F), - // 0x20 - new Rune(0x2588), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), - new Rune(0x0026), new Rune(0x0027), + // 0x30 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x28 - new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), - new Rune(0x002E), new Rune(0x002F), + // 0x38 + new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), + new Rune(0x003E), new Rune(0x003F), - // 0x30 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x40 + new Rune(0xF8FF), new Rune(0x0000), new Rune(0x1FBB0), new Rune(0x231B), new Rune(0x2713), + new Rune(0x1FBB1), new Rune(0x1FBB4), new Rune(0x1FB81), - // 0x38 - new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), - new Rune(0x003E), new Rune(0x003F), + // 0x48 + new Rune(0x2190), new Rune(0x2026), new Rune(0x2193), new Rune(0x2191), new Rune(0x2594), new Rune(0x21B5), + new Rune(0x2589), new Rune(0x1FBB5), - // 0x40 - new Rune(0xF8FF), new Rune(0x0000), new Rune(0x1FBB0), new Rune(0x231B), new Rune(0x2713), - new Rune(0x1FBB1), new Rune(0x1FBB4), new Rune(0x1FB81), + // 0x50 + new Rune(0x1FBB6), new Rune(0x1FBB7), new Rune(0x1FBB8), new Rune(0x2500), new Rune(0x1FB7C), + new Rune(0x2192), new Rune(0x2592), new Rune(0x1FB90), - // 0x48 - new Rune(0x2190), new Rune(0x2026), new Rune(0x2193), new Rune(0x2191), new Rune(0x2594), new Rune(0x21B5), - new Rune(0x2589), new Rune(0x1FBB5), + // 0x58 + new Rune(0x1FBB9), new Rune(0x1FBBA), new Rune(0x2595), new Rune(0x25C6), new Rune(0x1FB80), + new Rune(0x1FBBB), new Rune(0x1FBBC), new Rune(0x258F), - // 0x50 - new Rune(0x1FBB6), new Rune(0x1FBB7), new Rune(0x1FBB8), new Rune(0x2500), new Rune(0x1FB7C), - new Rune(0x2192), new Rune(0x2592), new Rune(0x1FB90), + // 0x60 + new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), + new Rune(0x0066), new Rune(0x0067), - // 0x58 - new Rune(0x1FBB9), new Rune(0x1FBBA), new Rune(0x2595), new Rune(0x25C6), new Rune(0x1FB80), - new Rune(0x1FBBB), new Rune(0x1FBBC), new Rune(0x258F), + // 0x68 + new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), + new Rune(0x006E), new Rune(0x006F), - // 0x60 - new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), - new Rune(0x0066), new Rune(0x0067), + // 0x70 + new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), + new Rune(0x0076), new Rune(0x0077), - // 0x68 - new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), - new Rune(0x006E), new Rune(0x006F), + // 0x78 + new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), + new Rune(0x007E), new Rune(0x0000), - // 0x70 - new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), - new Rune(0x0076), new Rune(0x0077), + // 0x80 + new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), + new Rune(0x0046), new Rune(0x0047), - // 0x78 - new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), - new Rune(0x007E), new Rune(0x0000), + // 0x88 + new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), + new Rune(0x004E), new Rune(0x004F), - // 0x80 - new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), - new Rune(0x0046), new Rune(0x0047), + // 0x90 + new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), + new Rune(0x0056), new Rune(0x0057), - // 0x88 - new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), - new Rune(0x004E), new Rune(0x004F), + // 0x98 + new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), + new Rune(0x005E), new Rune(0x005F), - // 0x90 - new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), - new Rune(0x0056), new Rune(0x0057), + // 0xA0 + new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), + new Rune(0x0026), new Rune(0x0027), - // 0x98 - new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), - new Rune(0x005E), new Rune(0x005F), + // 0xA8 + new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), + new Rune(0x002E), new Rune(0x002F), - // 0xA0 - new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), - new Rune(0x0026), new Rune(0x0027), + // 0xB0 + new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), + new Rune(0x0036), new Rune(0x0037), - // 0xA8 - new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), - new Rune(0x002E), new Rune(0x002F), + // 0xB8 + new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), + new Rune(0x003E), new Rune(0x003F), - // 0xB0 - new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), - new Rune(0x0036), new Rune(0x0037), + // 0xC0 + new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), + new Rune(0x0046), new Rune(0x0047), - // 0xB8 - new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), - new Rune(0x003E), new Rune(0x003F), + // 0xC8 + new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), + new Rune(0x004E), new Rune(0x004F), - // 0xC0 - new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), - new Rune(0x0046), new Rune(0x0047), + // 0xD0 + new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), + new Rune(0x0056), new Rune(0x0057), - // 0xC8 - new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), - new Rune(0x004E), new Rune(0x004F), + // 0xD8 + new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), + new Rune(0x005E), new Rune(0x005F), - // 0xD0 - new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), - new Rune(0x0056), new Rune(0x0057), + // 0xE0 + new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), + new Rune(0x0066), new Rune(0x0067), - // 0xD8 - new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), - new Rune(0x005E), new Rune(0x005F), + // 0xE8 + new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), + new Rune(0x006E), new Rune(0x006F), - // 0xE0 - new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), - new Rune(0x0066), new Rune(0x0067), + // 0xF0 + new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), + new Rune(0x0076), new Rune(0x0077), - // 0xE8 - new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), - new Rune(0x006E), new Rune(0x006F), + // 0xF8 + new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), + new Rune(0x007E), new Rune(0x0000) + }; - // 0xF0 - new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), - new Rune(0x0076), new Rune(0x0077), - - // 0xF8 - new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), - new Rune(0x007E), new Rune(0x0000) - }; - - /// Converts a Unicode character to an Apple IIgs character - /// Apple IIgs character. - /// Unicode character. - private protected override byte GetByte(Rune character) => character.Value switch - { - 0x2588 => 0x20, - 0xF8FF => 0x40, - 0x1FBB0 => 0x42, - 0x231B => 0x43, - 0x2713 => 0x44, - 0x1FBB1 => 0x45, - 0x1FBB4 => 0x46, - 0x1FB81 => 0x47, - 0x2190 => 0x48, - 0x2026 => 0x49, - 0x2193 => 0x4A, - 0x2191 => 0x4B, - 0x2594 => 0x4C, - 0x21B5 => 0x4D, - 0x2589 => 0x4E, - 0x1FBB5 => 0x4F, - 0x1FBB6 => 0x50, - 0x1FBB7 => 0x51, - 0x1FBB8 => 0x52, - 0x2500 => 0x53, - 0x1FB7C => 0x54, - 0x2192 => 0x55, - 0x2592 => 0x56, - 0x1FB90 => 0x57, - 0x1FBB9 => 0x58, - 0x1FBBA => 0x59, - 0x2595 => 0x5A, - 0x25C6 => 0x5B, - 0x1FB80 => 0x5C, - 0x1FBBB => 0x5D, - 0x1FBBC => 0x5E, - 0x258F => 0x5F, - 0x0040 => 0x80, - 0x0041 => 0x81, - 0x0042 => 0x82, - 0x0043 => 0x83, - 0x0044 => 0x84, - 0x0045 => 0x85, - 0x0046 => 0x86, - 0x0047 => 0x87, - 0x0048 => 0x88, - 0x0049 => 0x89, - 0x004A => 0x8A, - 0x004B => 0x8B, - 0x004C => 0x8C, - 0x004D => 0x8D, - 0x004E => 0x8E, - 0x004F => 0x8F, - 0x0050 => 0x90, - 0x0051 => 0x91, - 0x0052 => 0x92, - 0x0053 => 0x93, - 0x0054 => 0x94, - 0x0055 => 0x95, - 0x0056 => 0x96, - 0x0057 => 0x97, - 0x0058 => 0x98, - 0x0059 => 0x99, - 0x005A => 0x9A, - 0x005B => 0x9B, - 0x005C => 0x9C, - 0x005D => 0x9D, - 0x005E => 0x9E, - 0x005F => 0x9F, - 0x0020 => 0xA0, - 0x0021 => 0xA1, - 0x0022 => 0xA2, - 0x0023 => 0xA3, - 0x0024 => 0xA4, - 0x2025 => 0xA5, - 0x0026 => 0xA6, - 0x0027 => 0xA7, - 0x0028 => 0xA8, - 0x0029 => 0xA9, - 0x002A => 0xAA, - 0x002B => 0xAB, - 0x002C => 0xAC, - 0x002D => 0xAD, - 0x002E => 0xAE, - 0x002F => 0xAF, - 0x0030 => 0xB0, - 0x0031 => 0xB1, - 0x0032 => 0xB2, - 0x0033 => 0xB3, - 0x0034 => 0xB4, - 0x0035 => 0xB5, - 0x0036 => 0xB6, - 0x0037 => 0xB7, - 0x0038 => 0xB8, - 0x0039 => 0xB9, - 0x003A => 0xBA, - 0x003B => 0xBB, - 0x003C => 0xBC, - 0x003D => 0xBD, - 0x003E => 0xBE, - 0x003F => 0xBF, - 0x0060 => 0xE0, - 0x0061 => 0xE1, - 0x0062 => 0xE2, - 0x0063 => 0xE3, - 0x0064 => 0xE4, - 0x0065 => 0xE5, - 0x0066 => 0xE6, - 0x0067 => 0xE7, - 0x0068 => 0xE8, - 0x0069 => 0xE9, - 0x006A => 0xEA, - 0x006B => 0xEB, - 0x006C => 0xEC, - 0x006D => 0xED, - 0x006E => 0xEE, - 0x006F => 0xEF, - 0x0070 => 0xF0, - 0x0071 => 0xF1, - 0x0072 => 0xF2, - 0x0073 => 0xF3, - 0x0074 => 0xF4, - 0x0075 => 0xF5, - 0x0076 => 0xF6, - 0x0077 => 0xF7, - 0x0078 => 0xF8, - 0x0079 => 0xF9, - 0x007A => 0xFA, - 0x007B => 0xFB, - 0x007C => 0xFC, - 0x007D => 0xFD, - 0x007E => 0xFE, - _ => 0xBF - }; - } + /// Converts a Unicode character to an Apple IIgs character + /// Apple IIgs character. + /// Unicode character. + private protected override byte GetByte(Rune character) => character.Value switch + { + 0x2588 => 0x20, + 0xF8FF => 0x40, + 0x1FBB0 => 0x42, + 0x231B => 0x43, + 0x2713 => 0x44, + 0x1FBB1 => 0x45, + 0x1FBB4 => 0x46, + 0x1FB81 => 0x47, + 0x2190 => 0x48, + 0x2026 => 0x49, + 0x2193 => 0x4A, + 0x2191 => 0x4B, + 0x2594 => 0x4C, + 0x21B5 => 0x4D, + 0x2589 => 0x4E, + 0x1FBB5 => 0x4F, + 0x1FBB6 => 0x50, + 0x1FBB7 => 0x51, + 0x1FBB8 => 0x52, + 0x2500 => 0x53, + 0x1FB7C => 0x54, + 0x2192 => 0x55, + 0x2592 => 0x56, + 0x1FB90 => 0x57, + 0x1FBB9 => 0x58, + 0x1FBBA => 0x59, + 0x2595 => 0x5A, + 0x25C6 => 0x5B, + 0x1FB80 => 0x5C, + 0x1FBBB => 0x5D, + 0x1FBBC => 0x5E, + 0x258F => 0x5F, + 0x0040 => 0x80, + 0x0041 => 0x81, + 0x0042 => 0x82, + 0x0043 => 0x83, + 0x0044 => 0x84, + 0x0045 => 0x85, + 0x0046 => 0x86, + 0x0047 => 0x87, + 0x0048 => 0x88, + 0x0049 => 0x89, + 0x004A => 0x8A, + 0x004B => 0x8B, + 0x004C => 0x8C, + 0x004D => 0x8D, + 0x004E => 0x8E, + 0x004F => 0x8F, + 0x0050 => 0x90, + 0x0051 => 0x91, + 0x0052 => 0x92, + 0x0053 => 0x93, + 0x0054 => 0x94, + 0x0055 => 0x95, + 0x0056 => 0x96, + 0x0057 => 0x97, + 0x0058 => 0x98, + 0x0059 => 0x99, + 0x005A => 0x9A, + 0x005B => 0x9B, + 0x005C => 0x9C, + 0x005D => 0x9D, + 0x005E => 0x9E, + 0x005F => 0x9F, + 0x0020 => 0xA0, + 0x0021 => 0xA1, + 0x0022 => 0xA2, + 0x0023 => 0xA3, + 0x0024 => 0xA4, + 0x2025 => 0xA5, + 0x0026 => 0xA6, + 0x0027 => 0xA7, + 0x0028 => 0xA8, + 0x0029 => 0xA9, + 0x002A => 0xAA, + 0x002B => 0xAB, + 0x002C => 0xAC, + 0x002D => 0xAD, + 0x002E => 0xAE, + 0x002F => 0xAF, + 0x0030 => 0xB0, + 0x0031 => 0xB1, + 0x0032 => 0xB2, + 0x0033 => 0xB3, + 0x0034 => 0xB4, + 0x0035 => 0xB5, + 0x0036 => 0xB6, + 0x0037 => 0xB7, + 0x0038 => 0xB8, + 0x0039 => 0xB9, + 0x003A => 0xBA, + 0x003B => 0xBB, + 0x003C => 0xBC, + 0x003D => 0xBD, + 0x003E => 0xBE, + 0x003F => 0xBF, + 0x0060 => 0xE0, + 0x0061 => 0xE1, + 0x0062 => 0xE2, + 0x0063 => 0xE3, + 0x0064 => 0xE4, + 0x0065 => 0xE5, + 0x0066 => 0xE6, + 0x0067 => 0xE7, + 0x0068 => 0xE8, + 0x0069 => 0xE9, + 0x006A => 0xEA, + 0x006B => 0xEB, + 0x006C => 0xEC, + 0x006D => 0xED, + 0x006E => 0xEE, + 0x006F => 0xEF, + 0x0070 => 0xF0, + 0x0071 => 0xF1, + 0x0072 => 0xF2, + 0x0073 => 0xF3, + 0x0074 => 0xF4, + 0x0075 => 0xF5, + 0x0076 => 0xF6, + 0x0077 => 0xF7, + 0x0078 => 0xF8, + 0x0079 => 0xF9, + 0x007A => 0xFA, + 0x007B => 0xFB, + 0x007C => 0xFC, + 0x007D => 0xFD, + 0x007E => 0xFE, + _ => 0xBF + }; } \ No newline at end of file diff --git a/Claunia.Encoding/AtariST.cs b/Claunia.Encoding/AtariST.cs index 57211e0..2c52f50 100644 --- a/Claunia.Encoding/AtariST.cs +++ b/Claunia.Encoding/AtariST.cs @@ -26,426 +26,425 @@ using System.Text; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Atari ST character encoding of Unicode characters. +public class AtariST : SingleByteEncodingWithRunes { - /// Represents an Atari ST character encoding of Unicode characters. - public class AtariST : SingleByteEncodingWithRunes + /// + public override string BodyName => "atarist"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Western European (Atari ST)"; + /// + public override string HeaderName => "atarist"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => true; + + /// The Atari ST to Unicode character map. + protected override Rune[] CharTable => new[] { - /// - public override string BodyName => "atarist"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Western European (Atari ST)"; - /// - public override string HeaderName => "atarist"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + new Rune(0x0000), new Rune(0x21E7), new Rune(0x21E9), new Rune(0x21E8), new Rune(0x21E6), new Rune(0x1FBBD), + new Rune(0x1FBBE), new Rune(0x1FBBF), - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => true; + // 0x08 + new Rune(0x2713), new Rune(0x1F552), new Rune(0x1F514), new Rune(0x266A), new Rune(0x000C), + new Rune(0x000D), new Rune(0xFFFD), new Rune(0xFFFD), - /// The Atari ST to Unicode character map. - protected override Rune[] CharTable => new[] - { - // 0x00 - new Rune(0x0000), new Rune(0x21E7), new Rune(0x21E9), new Rune(0x21E8), new Rune(0x21E6), new Rune(0x1FBBD), - new Rune(0x1FBBE), new Rune(0x1FBBF), + // 0x10 + new Rune(0x1FBF0), new Rune(0x1FBF1), new Rune(0x1FBF2), new Rune(0x1FBF3), new Rune(0x1FBF4), + new Rune(0x1FBF5), new Rune(0x1FBF6), new Rune(0x1FBF7), - // 0x08 - new Rune(0x2713), new Rune(0x1F552), new Rune(0x1F514), new Rune(0x266A), new Rune(0x000C), - new Rune(0x000D), new Rune(0xFFFD), new Rune(0xFFFD), + // 0x18 + new Rune(0x1FBF8), new Rune(0x1FBF9), new Rune(0x0259), new Rune(0x001B), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - // 0x10 - new Rune(0x1FBF0), new Rune(0x1FBF1), new Rune(0x1FBF2), new Rune(0x1FBF3), new Rune(0x1FBF4), - new Rune(0x1FBF5), new Rune(0x1FBF6), new Rune(0x1FBF7), + // 0x20 + new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), + new Rune(0x0026), new Rune(0x0027), - // 0x18 - new Rune(0x1FBF8), new Rune(0x1FBF9), new Rune(0x0259), new Rune(0x001B), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + // 0x28 + new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), + new Rune(0x002E), new Rune(0x002F), - // 0x20 - new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), - new Rune(0x0026), new Rune(0x0027), + // 0x30 + new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), + new Rune(0x0036), new Rune(0x0037), - // 0x28 - new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), - new Rune(0x002E), new Rune(0x002F), + // 0x38 + new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), + new Rune(0x003E), new Rune(0x003F), - // 0x30 - new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), - new Rune(0x0036), new Rune(0x0037), + // 0x40 + new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), + new Rune(0x0046), new Rune(0x0047), - // 0x38 - new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), - new Rune(0x003E), new Rune(0x003F), + // 0x48 + new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), + new Rune(0x004E), new Rune(0x004F), - // 0x40 - new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), - new Rune(0x0046), new Rune(0x0047), + // 0x50 + new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), + new Rune(0x0056), new Rune(0x0057), - // 0x48 - new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), - new Rune(0x004E), new Rune(0x004F), + // 0x58 + new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), + new Rune(0x005E), new Rune(0x005F), - // 0x50 - new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), - new Rune(0x0056), new Rune(0x0057), + // 0x60 + new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), + new Rune(0x0066), new Rune(0x0067), - // 0x58 - new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), - new Rune(0x005E), new Rune(0x005F), + // 0x68 + new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), + new Rune(0x006E), new Rune(0x006F), - // 0x60 - new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), - new Rune(0x0066), new Rune(0x0067), + // 0x70 + new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), + new Rune(0x0076), new Rune(0x0077), - // 0x68 - new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), - new Rune(0x006E), new Rune(0x006F), + // 0x78 + new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), + new Rune(0x007E), new Rune(0x2302), - // 0x70 - new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), - new Rune(0x0076), new Rune(0x0077), + // 0x80 + new Rune(0x00C7), new Rune(0x00FC), new Rune(0x00E9), new Rune(0x00E2), new Rune(0x00E4), new Rune(0x00E0), + new Rune(0x00E5), new Rune(0x00E7), - // 0x78 - new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), - new Rune(0x007E), new Rune(0x2302), + // 0x88 + new Rune(0x00EA), new Rune(0x00EB), new Rune(0x00E8), new Rune(0x00EF), new Rune(0x00EE), new Rune(0x00EC), + new Rune(0x00C4), new Rune(0x00C5), - // 0x80 - new Rune(0x00C7), new Rune(0x00FC), new Rune(0x00E9), new Rune(0x00E2), new Rune(0x00E4), new Rune(0x00E0), - new Rune(0x00E5), new Rune(0x00E7), + // 0x90 + new Rune(0x00C9), new Rune(0x00E6), new Rune(0x00C6), new Rune(0x00F4), new Rune(0x00F6), new Rune(0x00F2), + new Rune(0x00FB), new Rune(0x00F9), - // 0x88 - new Rune(0x00EA), new Rune(0x00EB), new Rune(0x00E8), new Rune(0x00EF), new Rune(0x00EE), new Rune(0x00EC), - new Rune(0x00C4), new Rune(0x00C5), + // 0x98 + new Rune(0x00FF), new Rune(0x00D6), new Rune(0x00DC), new Rune(0x00A2), new Rune(0x00A3), new Rune(0x00A5), + new Rune(0x00DF), new Rune(0x0192), - // 0x90 - new Rune(0x00C9), new Rune(0x00E6), new Rune(0x00C6), new Rune(0x00F4), new Rune(0x00F6), new Rune(0x00F2), - new Rune(0x00FB), new Rune(0x00F9), + // 0xA0 + new Rune(0x00E1), new Rune(0x00ED), new Rune(0x00F3), new Rune(0x00FA), new Rune(0x00F1), new Rune(0x00D1), + new Rune(0x00AA), new Rune(0x00BA), - // 0x98 - new Rune(0x00FF), new Rune(0x00D6), new Rune(0x00DC), new Rune(0x00A2), new Rune(0x00A3), new Rune(0x00A5), - new Rune(0x00DF), new Rune(0x0192), + // 0xA8 + new Rune(0x00BF), new Rune(0x2310), new Rune(0x00AC), new Rune(0x00BD), new Rune(0x00BC), new Rune(0x00A1), + new Rune(0x00AB), new Rune(0x00BB), - // 0xA0 - new Rune(0x00E1), new Rune(0x00ED), new Rune(0x00F3), new Rune(0x00FA), new Rune(0x00F1), new Rune(0x00D1), - new Rune(0x00AA), new Rune(0x00BA), + // 0xB0 + new Rune(0x00E3), new Rune(0x00F5), new Rune(0x00D8), new Rune(0x00F8), new Rune(0x0153), new Rune(0x0152), + new Rune(0x00C0), new Rune(0x00C3), - // 0xA8 - new Rune(0x00BF), new Rune(0x2310), new Rune(0x00AC), new Rune(0x00BD), new Rune(0x00BC), new Rune(0x00A1), - new Rune(0x00AB), new Rune(0x00BB), + // 0xB8 + new Rune(0x00D5), new Rune(0x00A8), new Rune(0x00B4), new Rune(0x2020), new Rune(0x00B6), new Rune(0x00A9), + new Rune(0x00AE), new Rune(0x2122), - // 0xB0 - new Rune(0x00E3), new Rune(0x00F5), new Rune(0x00D8), new Rune(0x00F8), new Rune(0x0153), new Rune(0x0152), - new Rune(0x00C0), new Rune(0x00C3), + // 0xC0 + new Rune(0x0133), new Rune(0x0132), new Rune(0x05D0), new Rune(0x05D1), new Rune(0x05D2), new Rune(0x05D3), + new Rune(0x05D4), new Rune(0x05D5), - // 0xB8 - new Rune(0x00D5), new Rune(0x00A8), new Rune(0x00B4), new Rune(0x2020), new Rune(0x00B6), new Rune(0x00A9), - new Rune(0x00AE), new Rune(0x2122), + // 0xC8 + new Rune(0x05D6), new Rune(0x05D7), new Rune(0x05D8), new Rune(0x05D9), new Rune(0x05DB), new Rune(0x05DC), + new Rune(0x05DE), new Rune(0x05E0), - // 0xC0 - new Rune(0x0133), new Rune(0x0132), new Rune(0x05D0), new Rune(0x05D1), new Rune(0x05D2), new Rune(0x05D3), - new Rune(0x05D4), new Rune(0x05D5), + // 0xD0 + new Rune(0x05E1), new Rune(0x05E2), new Rune(0x05E4), new Rune(0x05E6), new Rune(0x05E7), new Rune(0x05E8), + new Rune(0x05E9), new Rune(0x05EA), - // 0xC8 - new Rune(0x05D6), new Rune(0x05D7), new Rune(0x05D8), new Rune(0x05D9), new Rune(0x05DB), new Rune(0x05DC), - new Rune(0x05DE), new Rune(0x05E0), + // 0xD8 + new Rune(0x05DF), new Rune(0x05DA), new Rune(0x05DD), new Rune(0x05E3), new Rune(0x05E5), new Rune(0x00A7), + new Rune(0x2227), new Rune(0x221E), - // 0xD0 - new Rune(0x05E1), new Rune(0x05E2), new Rune(0x05E4), new Rune(0x05E6), new Rune(0x05E7), new Rune(0x05E8), - new Rune(0x05E9), new Rune(0x05EA), + // 0xE0 + new Rune(0x03B1), new Rune(0x03B2), new Rune(0x0393), new Rune(0x03C0), new Rune(0x03A3), new Rune(0x03C3), + new Rune(0x00B5), new Rune(0x03C4), - // 0xD8 - new Rune(0x05DF), new Rune(0x05DA), new Rune(0x05DD), new Rune(0x05E3), new Rune(0x05E5), new Rune(0x00A7), - new Rune(0x2227), new Rune(0x221E), + // 0xE8 + new Rune(0x03A6), new Rune(0x0398), new Rune(0x03A9), new Rune(0x03B4), new Rune(0x222E), new Rune(0x03D5), + new Rune(0x2208), new Rune(0x2229), - // 0xE0 - new Rune(0x03B1), new Rune(0x03B2), new Rune(0x0393), new Rune(0x03C0), new Rune(0x03A3), new Rune(0x03C3), - new Rune(0x00B5), new Rune(0x03C4), + // 0xF0 + new Rune(0x2261), new Rune(0x00B1), new Rune(0x2265), new Rune(0x2264), new Rune(0x2320), new Rune(0x2321), + new Rune(0x00F7), new Rune(0x2248), - // 0xE8 - new Rune(0x03A6), new Rune(0x0398), new Rune(0x03A9), new Rune(0x03B4), new Rune(0x222E), new Rune(0x03D5), - new Rune(0x2208), new Rune(0x2229), + // 0xF8 + new Rune(0x00B0), new Rune(0x2219), new Rune(0x00B7), new Rune(0x221A), new Rune(0x207F), new Rune(0x00B2), + new Rune(0x00B3), new Rune(0x00AF) + }; - // 0xF0 - new Rune(0x2261), new Rune(0x00B1), new Rune(0x2265), new Rune(0x2264), new Rune(0x2320), new Rune(0x2321), - new Rune(0x00F7), new Rune(0x2248), - - // 0xF8 - new Rune(0x00B0), new Rune(0x2219), new Rune(0x00B7), new Rune(0x221A), new Rune(0x207F), new Rune(0x00B2), - new Rune(0x00B3), new Rune(0x00AF) - }; - - /// Converts a Unicode character to an Atari ST character - /// Atari ST character. - /// Unicode character. - private protected override byte GetByte(Rune character) => character.Value switch - { - 0x0000 => 0x00, - 0x21E7 => 0x01, - 0x21E9 => 0x02, - 0x21E8 => 0x03, - 0x21E6 => 0x04, - 0x274E => 0x05, - 0x1FBBD => 0x05, - 0x1FBBE => 0x06, - 0x1FBBF => 0x07, - 0x2713 => 0x08, - 0x1F552 => 0x09, - 0x1F514 => 0x0A, - 0x266A => 0x0B, - 0x000C => 0x0C, - 0x000D => 0x0D, - 0x1FBF0 => 0x10, - 0x1FBF1 => 0x11, - 0x1FBF2 => 0x12, - 0x1FBF3 => 0x13, - 0x1FBF4 => 0x14, - 0x1FBF5 => 0x15, - 0x1FBF6 => 0x16, - 0x1FBF7 => 0x17, - 0x1FBF8 => 0x18, - 0x1FBF9 => 0x19, - 0x0259 => 0x1A, - 0x001B => 0x1B, - 0x0020 => 0x20, - 0x0021 => 0x21, - 0x0022 => 0x22, - 0x0023 => 0x23, - 0x0024 => 0x24, - 0x0025 => 0x25, - 0x0026 => 0x26, - 0x0027 => 0x27, - 0x0028 => 0x28, - 0x0029 => 0x29, - 0x002A => 0x2A, - 0x002B => 0x2B, - 0x002C => 0x2C, - 0x002D => 0x2D, - 0x002E => 0x2E, - 0x002F => 0x2F, - 0x0030 => 0x30, - 0x0031 => 0x31, - 0x0032 => 0x32, - 0x0033 => 0x33, - 0x0034 => 0x34, - 0x0035 => 0x35, - 0x0036 => 0x36, - 0x0037 => 0x37, - 0x0038 => 0x38, - 0x0039 => 0x39, - 0x003A => 0x3A, - 0x003B => 0x3B, - 0x003C => 0x3C, - 0x003D => 0x3D, - 0x003E => 0x3E, - 0x003F => 0x3F, - 0x0040 => 0x40, - 0x0041 => 0x41, - 0x0042 => 0x42, - 0x0043 => 0x43, - 0x0044 => 0x44, - 0x0045 => 0x45, - 0x0046 => 0x46, - 0x0047 => 0x47, - 0x0048 => 0x48, - 0x0049 => 0x49, - 0x004A => 0x4A, - 0x004B => 0x4B, - 0x004C => 0x4C, - 0x004D => 0x4D, - 0x004E => 0x4E, - 0x004F => 0x4F, - 0x0050 => 0x50, - 0x0051 => 0x51, - 0x0052 => 0x52, - 0x0053 => 0x53, - 0x0054 => 0x54, - 0x0055 => 0x55, - 0x0056 => 0x56, - 0x0057 => 0x57, - 0x0058 => 0x58, - 0x0059 => 0x59, - 0x005A => 0x5A, - 0x005B => 0x5B, - 0x005C => 0x5C, - 0x005D => 0x5D, - 0x005E => 0x5E, - 0x005F => 0x5F, - 0x0060 => 0x60, - 0x0061 => 0x61, - 0x0062 => 0x62, - 0x0063 => 0x63, - 0x0064 => 0x64, - 0x0065 => 0x65, - 0x0066 => 0x66, - 0x0067 => 0x67, - 0x0068 => 0x68, - 0x0069 => 0x69, - 0x006A => 0x6A, - 0x006B => 0x6B, - 0x006C => 0x6C, - 0x006D => 0x6D, - 0x006E => 0x6E, - 0x006F => 0x6F, - 0x0070 => 0x70, - 0x0071 => 0x71, - 0x0072 => 0x72, - 0x0073 => 0x73, - 0x0074 => 0x74, - 0x0075 => 0x75, - 0x0076 => 0x76, - 0x0077 => 0x77, - 0x0078 => 0x78, - 0x0079 => 0x79, - 0x007A => 0x7A, - 0x007B => 0x7B, - 0x007C => 0x7C, - 0x007D => 0x7D, - 0x007E => 0x7E, - 0x2302 => 0x7F, - 0x00C7 => 0x80, - 0x00FC => 0x81, - 0x00E9 => 0x82, - 0x00E2 => 0x83, - 0x00E4 => 0x84, - 0x00E0 => 0x85, - 0x00E5 => 0x86, - 0x00E7 => 0x87, - 0x00EA => 0x88, - 0x00EB => 0x89, - 0x00E8 => 0x8A, - 0x00EF => 0x8B, - 0x00EE => 0x8C, - 0x00EC => 0x8D, - 0x00C4 => 0x8E, - 0x00C5 => 0x8F, - 0x00C9 => 0x90, - 0x00E6 => 0x91, - 0x00C6 => 0x92, - 0x00F4 => 0x93, - 0x00F6 => 0x94, - 0x00F2 => 0x95, - 0x00FB => 0x96, - 0x00F9 => 0x97, - 0x00FF => 0x98, - 0x00D6 => 0x99, - 0x00DC => 0x9A, - 0x00A2 => 0x9B, - 0x00A3 => 0x9C, - 0x00A5 => 0x9D, - 0x00DF => 0x9E, - 0x0192 => 0x9F, - 0x00E1 => 0xA0, - 0x00ED => 0xA1, - 0x00F3 => 0xA2, - 0x00FA => 0xA3, - 0x00F1 => 0xA4, - 0x00D1 => 0xA5, - 0x00AA => 0xA6, - 0x00BA => 0xA7, - 0x00BF => 0xA8, - 0x2310 => 0xA9, - 0x00AC => 0xAA, - 0x00BD => 0xAB, - 0x00BC => 0xAC, - 0x00A1 => 0xAD, - 0x00AB => 0xAE, - 0x00BB => 0xAF, - 0x00E3 => 0xB0, - 0x00F5 => 0xB1, - 0x00D8 => 0xB2, - 0x00F8 => 0xB3, - 0x0153 => 0xB4, - 0x0152 => 0xB5, - 0x00C0 => 0xB6, - 0x00C3 => 0xB7, - 0x00D5 => 0xB8, - 0x00A8 => 0xB9, - 0x00B4 => 0xBA, - 0x2020 => 0xBB, - 0x00B6 => 0xBC, - 0x00A9 => 0xBD, - 0x00AE => 0xBE, - 0x2122 => 0xBF, - 0x0133 => 0xC0, - 0x0132 => 0xC1, - 0x05D0 => 0xC2, - 0x05D1 => 0xC3, - 0x05D2 => 0xC4, - 0x05D3 => 0xC5, - 0x05D4 => 0xC6, - 0x05D5 => 0xC7, - 0x05D6 => 0xC8, - 0x05D7 => 0xC9, - 0x05D8 => 0xCA, - 0x05D9 => 0xCB, - 0x05DB => 0xCC, - 0x05DC => 0xCD, - 0x05DE => 0xCE, - 0x05E0 => 0xCF, - 0x05E1 => 0xD0, - 0x05E2 => 0xD1, - 0x05E4 => 0xD2, - 0x05E6 => 0xD3, - 0x05E7 => 0xD4, - 0x05E8 => 0xD5, - 0x05E9 => 0xD6, - 0x05EA => 0xD7, - 0x05DF => 0xD8, - 0x05DA => 0xD9, - 0x05DD => 0xDA, - 0x05E3 => 0xDB, - 0x05E5 => 0xDC, - 0x00A7 => 0xDD, - 0x2227 => 0xDE, - 0x221E => 0xDF, - 0x03B1 => 0xE0, - 0x03B2 => 0xE1, - 0x0393 => 0xE2, - 0x03C0 => 0xE3, - 0x03A3 => 0xE4, - 0x03C3 => 0xE5, - 0x00B5 => 0xE6, - 0x03C4 => 0xE7, - 0x03A6 => 0xE8, - 0x0398 => 0xE9, - 0x03A9 => 0xEA, - 0x03B4 => 0xEB, - 0x222E => 0xEC, - 0x03D5 => 0xED, - 0x2208 => 0xEE, - 0x2229 => 0xEF, - 0x2261 => 0xF0, - 0x00B1 => 0xF1, - 0x2265 => 0xF2, - 0x2264 => 0xF3, - 0x2320 => 0xF4, - 0x2321 => 0xF5, - 0x00F7 => 0xF6, - 0x2248 => 0xF7, - 0x00B0 => 0xF8, - 0x2219 => 0xF9, - 0x00B7 => 0xFA, - 0x221A => 0xFB, - 0x207F => 0xFC, - 0x00B2 => 0xFD, - 0x00B3 => 0xFE, - 0x00AF => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Atari ST character + /// Atari ST character. + /// Unicode character. + private protected override byte GetByte(Rune character) => character.Value switch + { + 0x0000 => 0x00, + 0x21E7 => 0x01, + 0x21E9 => 0x02, + 0x21E8 => 0x03, + 0x21E6 => 0x04, + 0x274E => 0x05, + 0x1FBBD => 0x05, + 0x1FBBE => 0x06, + 0x1FBBF => 0x07, + 0x2713 => 0x08, + 0x1F552 => 0x09, + 0x1F514 => 0x0A, + 0x266A => 0x0B, + 0x000C => 0x0C, + 0x000D => 0x0D, + 0x1FBF0 => 0x10, + 0x1FBF1 => 0x11, + 0x1FBF2 => 0x12, + 0x1FBF3 => 0x13, + 0x1FBF4 => 0x14, + 0x1FBF5 => 0x15, + 0x1FBF6 => 0x16, + 0x1FBF7 => 0x17, + 0x1FBF8 => 0x18, + 0x1FBF9 => 0x19, + 0x0259 => 0x1A, + 0x001B => 0x1B, + 0x0020 => 0x20, + 0x0021 => 0x21, + 0x0022 => 0x22, + 0x0023 => 0x23, + 0x0024 => 0x24, + 0x0025 => 0x25, + 0x0026 => 0x26, + 0x0027 => 0x27, + 0x0028 => 0x28, + 0x0029 => 0x29, + 0x002A => 0x2A, + 0x002B => 0x2B, + 0x002C => 0x2C, + 0x002D => 0x2D, + 0x002E => 0x2E, + 0x002F => 0x2F, + 0x0030 => 0x30, + 0x0031 => 0x31, + 0x0032 => 0x32, + 0x0033 => 0x33, + 0x0034 => 0x34, + 0x0035 => 0x35, + 0x0036 => 0x36, + 0x0037 => 0x37, + 0x0038 => 0x38, + 0x0039 => 0x39, + 0x003A => 0x3A, + 0x003B => 0x3B, + 0x003C => 0x3C, + 0x003D => 0x3D, + 0x003E => 0x3E, + 0x003F => 0x3F, + 0x0040 => 0x40, + 0x0041 => 0x41, + 0x0042 => 0x42, + 0x0043 => 0x43, + 0x0044 => 0x44, + 0x0045 => 0x45, + 0x0046 => 0x46, + 0x0047 => 0x47, + 0x0048 => 0x48, + 0x0049 => 0x49, + 0x004A => 0x4A, + 0x004B => 0x4B, + 0x004C => 0x4C, + 0x004D => 0x4D, + 0x004E => 0x4E, + 0x004F => 0x4F, + 0x0050 => 0x50, + 0x0051 => 0x51, + 0x0052 => 0x52, + 0x0053 => 0x53, + 0x0054 => 0x54, + 0x0055 => 0x55, + 0x0056 => 0x56, + 0x0057 => 0x57, + 0x0058 => 0x58, + 0x0059 => 0x59, + 0x005A => 0x5A, + 0x005B => 0x5B, + 0x005C => 0x5C, + 0x005D => 0x5D, + 0x005E => 0x5E, + 0x005F => 0x5F, + 0x0060 => 0x60, + 0x0061 => 0x61, + 0x0062 => 0x62, + 0x0063 => 0x63, + 0x0064 => 0x64, + 0x0065 => 0x65, + 0x0066 => 0x66, + 0x0067 => 0x67, + 0x0068 => 0x68, + 0x0069 => 0x69, + 0x006A => 0x6A, + 0x006B => 0x6B, + 0x006C => 0x6C, + 0x006D => 0x6D, + 0x006E => 0x6E, + 0x006F => 0x6F, + 0x0070 => 0x70, + 0x0071 => 0x71, + 0x0072 => 0x72, + 0x0073 => 0x73, + 0x0074 => 0x74, + 0x0075 => 0x75, + 0x0076 => 0x76, + 0x0077 => 0x77, + 0x0078 => 0x78, + 0x0079 => 0x79, + 0x007A => 0x7A, + 0x007B => 0x7B, + 0x007C => 0x7C, + 0x007D => 0x7D, + 0x007E => 0x7E, + 0x2302 => 0x7F, + 0x00C7 => 0x80, + 0x00FC => 0x81, + 0x00E9 => 0x82, + 0x00E2 => 0x83, + 0x00E4 => 0x84, + 0x00E0 => 0x85, + 0x00E5 => 0x86, + 0x00E7 => 0x87, + 0x00EA => 0x88, + 0x00EB => 0x89, + 0x00E8 => 0x8A, + 0x00EF => 0x8B, + 0x00EE => 0x8C, + 0x00EC => 0x8D, + 0x00C4 => 0x8E, + 0x00C5 => 0x8F, + 0x00C9 => 0x90, + 0x00E6 => 0x91, + 0x00C6 => 0x92, + 0x00F4 => 0x93, + 0x00F6 => 0x94, + 0x00F2 => 0x95, + 0x00FB => 0x96, + 0x00F9 => 0x97, + 0x00FF => 0x98, + 0x00D6 => 0x99, + 0x00DC => 0x9A, + 0x00A2 => 0x9B, + 0x00A3 => 0x9C, + 0x00A5 => 0x9D, + 0x00DF => 0x9E, + 0x0192 => 0x9F, + 0x00E1 => 0xA0, + 0x00ED => 0xA1, + 0x00F3 => 0xA2, + 0x00FA => 0xA3, + 0x00F1 => 0xA4, + 0x00D1 => 0xA5, + 0x00AA => 0xA6, + 0x00BA => 0xA7, + 0x00BF => 0xA8, + 0x2310 => 0xA9, + 0x00AC => 0xAA, + 0x00BD => 0xAB, + 0x00BC => 0xAC, + 0x00A1 => 0xAD, + 0x00AB => 0xAE, + 0x00BB => 0xAF, + 0x00E3 => 0xB0, + 0x00F5 => 0xB1, + 0x00D8 => 0xB2, + 0x00F8 => 0xB3, + 0x0153 => 0xB4, + 0x0152 => 0xB5, + 0x00C0 => 0xB6, + 0x00C3 => 0xB7, + 0x00D5 => 0xB8, + 0x00A8 => 0xB9, + 0x00B4 => 0xBA, + 0x2020 => 0xBB, + 0x00B6 => 0xBC, + 0x00A9 => 0xBD, + 0x00AE => 0xBE, + 0x2122 => 0xBF, + 0x0133 => 0xC0, + 0x0132 => 0xC1, + 0x05D0 => 0xC2, + 0x05D1 => 0xC3, + 0x05D2 => 0xC4, + 0x05D3 => 0xC5, + 0x05D4 => 0xC6, + 0x05D5 => 0xC7, + 0x05D6 => 0xC8, + 0x05D7 => 0xC9, + 0x05D8 => 0xCA, + 0x05D9 => 0xCB, + 0x05DB => 0xCC, + 0x05DC => 0xCD, + 0x05DE => 0xCE, + 0x05E0 => 0xCF, + 0x05E1 => 0xD0, + 0x05E2 => 0xD1, + 0x05E4 => 0xD2, + 0x05E6 => 0xD3, + 0x05E7 => 0xD4, + 0x05E8 => 0xD5, + 0x05E9 => 0xD6, + 0x05EA => 0xD7, + 0x05DF => 0xD8, + 0x05DA => 0xD9, + 0x05DD => 0xDA, + 0x05E3 => 0xDB, + 0x05E5 => 0xDC, + 0x00A7 => 0xDD, + 0x2227 => 0xDE, + 0x221E => 0xDF, + 0x03B1 => 0xE0, + 0x03B2 => 0xE1, + 0x0393 => 0xE2, + 0x03C0 => 0xE3, + 0x03A3 => 0xE4, + 0x03C3 => 0xE5, + 0x00B5 => 0xE6, + 0x03C4 => 0xE7, + 0x03A6 => 0xE8, + 0x0398 => 0xE9, + 0x03A9 => 0xEA, + 0x03B4 => 0xEB, + 0x222E => 0xEC, + 0x03D5 => 0xED, + 0x2208 => 0xEE, + 0x2229 => 0xEF, + 0x2261 => 0xF0, + 0x00B1 => 0xF1, + 0x2265 => 0xF2, + 0x2264 => 0xF3, + 0x2320 => 0xF4, + 0x2321 => 0xF5, + 0x00F7 => 0xF6, + 0x2248 => 0xF7, + 0x00B0 => 0xF8, + 0x2219 => 0xF9, + 0x00B7 => 0xFA, + 0x221A => 0xFB, + 0x207F => 0xFC, + 0x00B2 => 0xFD, + 0x00B3 => 0xFE, + 0x00AF => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/Encoding.cs b/Claunia.Encoding/Encoding.cs index 7d18abf..dd117b8 100644 --- a/Claunia.Encoding/Encoding.cs +++ b/Claunia.Encoding/Encoding.cs @@ -29,97 +29,96 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// This class contains static instances of the supported encodings. +public abstract class Encoding : System.Text.Encoding { - /// This class contains static instances of the supported encodings. - public abstract class Encoding : System.Text.Encoding + /// Static instance for the LisaRoman encoding + public static System.Text.Encoding LisaEncoding = new LisaRoman(); + /// Static instance for the ATASCII encoding + public static System.Text.Encoding AtariEncoding = new ATASCII(); + /// Static instance for the Atari ST encoding + public static System.Text.Encoding AtariStEncoding = new AtariST(); + /// Static instance for the PETSCII encoding + public static System.Text.Encoding PetEncoding = new PETSCII(); + /// Static instance for the DEC Radix-50 encoding + public static System.Text.Encoding Radix50Encoding = new Radix50(); + /// Static instance for the GEM encoding + public static System.Text.Encoding GemEncoding = new GEM(); + /// Static instance for the GEM encoding + public static System.Text.Encoding GeosEncoding = new GEOS(); + + /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content. + public abstract override bool IsBrowserDisplay { get; } + + /// Gets a value indicating whether the current encoding can be used by browser clients for saving content. + public abstract override bool IsBrowserSave { get; } + + /// + /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying + /// content. + /// + public abstract override bool IsMailNewsDisplay { get; } + + /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content. + public abstract override bool IsMailNewsSave { get; } + + /// Gets a value indicating whether the current encoding is read-only. + /// The is single byte. + public new abstract bool IsReadOnly { get; } + + /// Gets a value indicating whether the current encoding uses single-byte code points. + public abstract override bool IsSingleByte { get; } + + /// Gets the code page identifier of the current Encoding. + public abstract override int CodePage { get; } + + /// Gets a name for the current encoding that can be used with mail agent body tags + public abstract override string BodyName { get; } + + /// Gets a name for the current encoding that can be used with mail agent header tags + public abstract override string HeaderName { get; } + + /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding. + public abstract override string WebName { get; } + + /// Gets the human-readable description of the current encoding. + public abstract override string EncodingName { get; } + + /// Gets the Windows operating system code page that most closely corresponds to the current encoding. + public abstract override int WindowsCodePage { get; } + + /// Returns an array that contains all encodings. + /// An array that contains all encodings. + public new static IEnumerable GetEncodings() => + from type in Assembly.GetExecutingAssembly().GetTypes() + where type.IsSubclassOf(typeof(Encoding)) && !type.IsAbstract let encoding = (Encoding)type. + GetConstructor(new Type[] + {})?.Invoke(new object[] + {}) where encoding is {} + select new EncodingInfo(encoding.CodePage, encoding.BodyName, encoding.EncodingName, false, type); + + /// Returns the encoding associated with the specified code page name. + /// The encoding associated with the specified code page. + /// + /// The code page name of the preferred encoding. Any value returned by the WebName property is valid. + /// Possible values are listed in the Name column of the table that appears in the Encoding class topic. + /// + public new static System.Text.Encoding GetEncoding(string name) { - /// Static instance for the LisaRoman encoding - public static System.Text.Encoding LisaEncoding = new LisaRoman(); - /// Static instance for the ATASCII encoding - public static System.Text.Encoding AtariEncoding = new ATASCII(); - /// Static instance for the Atari ST encoding - public static System.Text.Encoding AtariStEncoding = new AtariST(); - /// Static instance for the PETSCII encoding - public static System.Text.Encoding PetEncoding = new PETSCII(); - /// Static instance for the DEC Radix-50 encoding - public static System.Text.Encoding Radix50Encoding = new Radix50(); - /// Static instance for the GEM encoding - public static System.Text.Encoding GemEncoding = new GEM(); - /// Static instance for the GEM encoding - public static System.Text.Encoding GeosEncoding = new GEOS(); + foreach(Type type in Assembly.GetExecutingAssembly().GetTypes()) + if(type.IsSubclassOf(typeof(Encoding)) && + !type.IsAbstract) + { + var encoding = (Encoding)type.GetConstructor(new Type[] + {})?.Invoke(new object[] + {}); - /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content. - public abstract override bool IsBrowserDisplay { get; } + if(encoding?.BodyName == name.ToLowerInvariant()) + return encoding; + } - /// Gets a value indicating whether the current encoding can be used by browser clients for saving content. - public abstract override bool IsBrowserSave { get; } - - /// - /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying - /// content. - /// - public abstract override bool IsMailNewsDisplay { get; } - - /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content. - public abstract override bool IsMailNewsSave { get; } - - /// Gets a value indicating whether the current encoding is read-only. - /// The is single byte. - public new abstract bool IsReadOnly { get; } - - /// Gets a value indicating whether the current encoding uses single-byte code points. - public abstract override bool IsSingleByte { get; } - - /// Gets the code page identifier of the current Encoding. - public abstract override int CodePage { get; } - - /// Gets a name for the current encoding that can be used with mail agent body tags - public abstract override string BodyName { get; } - - /// Gets a name for the current encoding that can be used with mail agent header tags - public abstract override string HeaderName { get; } - - /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding. - public abstract override string WebName { get; } - - /// Gets the human-readable description of the current encoding. - public abstract override string EncodingName { get; } - - /// Gets the Windows operating system code page that most closely corresponds to the current encoding. - public abstract override int WindowsCodePage { get; } - - /// Returns an array that contains all encodings. - /// An array that contains all encodings. - public new static IEnumerable GetEncodings() => - from type in Assembly.GetExecutingAssembly().GetTypes() - where type.IsSubclassOf(typeof(Encoding)) && !type.IsAbstract let encoding = (Encoding)type. - GetConstructor(new Type[] - {})?.Invoke(new object[] - {}) where encoding is {} - select new EncodingInfo(encoding.CodePage, encoding.BodyName, encoding.EncodingName, false, type); - - /// Returns the encoding associated with the specified code page name. - /// The encoding associated with the specified code page. - /// - /// The code page name of the preferred encoding. Any value returned by the WebName property is valid. - /// Possible values are listed in the Name column of the table that appears in the Encoding class topic. - /// - public new static System.Text.Encoding GetEncoding(string name) - { - foreach(Type type in Assembly.GetExecutingAssembly().GetTypes()) - if(type.IsSubclassOf(typeof(Encoding)) && - !type.IsAbstract) - { - var encoding = (Encoding)type.GetConstructor(new Type[] - {})?.Invoke(new object[] - {}); - - if(encoding?.BodyName == name.ToLowerInvariant()) - return encoding; - } - - return System.Text.Encoding.GetEncoding(name); - } + return System.Text.Encoding.GetEncoding(name); } } \ No newline at end of file diff --git a/Claunia.Encoding/EncodingInfo.cs b/Claunia.Encoding/EncodingInfo.cs index 53ddfe5..0ad47b6 100644 --- a/Claunia.Encoding/EncodingInfo.cs +++ b/Claunia.Encoding/EncodingInfo.cs @@ -4,55 +4,54 @@ using System; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Provides basic information about an encoding. +public sealed class EncodingInfo { - /// Provides basic information about an encoding. - public sealed class EncodingInfo + readonly Type _thisType; + bool _isSystem; + + internal EncodingInfo(int codePage, string name, string displayName, bool system = true, + Type internalType = null) { - readonly Type _thisType; - bool _isSystem; - - internal EncodingInfo(int codePage, string name, string displayName, bool system = true, - Type internalType = null) - { - CodePage = codePage; - Name = name; - DisplayName = displayName; - _isSystem = system; - _thisType = internalType; - } - - /// Gets the code page identifier of the encoding. - /// The code page identifier of the encoding. - public int CodePage { get; } - - /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the encoding. - /// The IANA name for the encoding. For more information about the IANA, see www.iana.org. - public string Name { get; } - - /// Gets the human-readable description of the encoding. - /// The human-readable description of the encoding. - public string DisplayName { get; } - - /// Returns a Encoding object that corresponds to the current EncodingInfo object. - /// - /// A object that corresponds to the current - /// object. - /// - public Encoding GetEncoding() => (Encoding)_thisType.GetConstructor(new Type[] - {}).Invoke(new object[] - {}); - - /// Gets a value indicating whether the specified object is equal to the current EncodingInfo object. - /// An object to compare to the current object. - /// - /// true if value is a and is equal to the current - /// ; otherwise, false. - /// - public override bool Equals(object value) => value is EncodingInfo that && CodePage == that.CodePage; - - /// Returns the hash code for the current EncodingInfo object. - /// A 32-bit signed integer hash code. - public override int GetHashCode() => CodePage; + CodePage = codePage; + Name = name; + DisplayName = displayName; + _isSystem = system; + _thisType = internalType; } + + /// Gets the code page identifier of the encoding. + /// The code page identifier of the encoding. + public int CodePage { get; } + + /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the encoding. + /// The IANA name for the encoding. For more information about the IANA, see www.iana.org. + public string Name { get; } + + /// Gets the human-readable description of the encoding. + /// The human-readable description of the encoding. + public string DisplayName { get; } + + /// Returns a Encoding object that corresponds to the current EncodingInfo object. + /// + /// A object that corresponds to the current + /// object. + /// + public Encoding GetEncoding() => (Encoding)_thisType.GetConstructor(new Type[] + {}).Invoke(new object[] + {}); + + /// Gets a value indicating whether the specified object is equal to the current EncodingInfo object. + /// An object to compare to the current object. + /// + /// true if value is a and is equal to the current + /// ; otherwise, false. + /// + public override bool Equals(object value) => value is EncodingInfo that && CodePage == that.CodePage; + + /// Returns the hash code for the current EncodingInfo object. + /// A 32-bit signed integer hash code. + public override int GetHashCode() => CodePage; } \ No newline at end of file diff --git a/Claunia.Encoding/GEM.cs b/Claunia.Encoding/GEM.cs index 9164fbf..6cd5d54 100644 --- a/Claunia.Encoding/GEM.cs +++ b/Claunia.Encoding/GEM.cs @@ -26,423 +26,422 @@ using System.Text; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents a GEM character encoding of Unicode characters. +public class GEM : SingleByteEncodingWithRunes { - /// Represents a GEM character encoding of Unicode characters. - public class GEM : SingleByteEncodingWithRunes + /// + public override string BodyName => "gem"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Western European (GEM)"; + /// + public override string HeaderName => "gem"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => true; + + /// The GEM to Unicode character map. + protected override Rune[] CharTable => new[] { - /// - public override string BodyName => "gem"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Western European (GEM)"; - /// - public override string HeaderName => "gem"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + new Rune(0x0000), new Rune(0x21E7), new Rune(0x21E9), new Rune(0x21E8), new Rune(0x21E6), new Rune(0x25FC), + new Rune(0x1F5D7), new Rune(0x25C6), - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => true; + // 0x08 + new Rune(0x2713), new Rune(0x1F552), new Rune(0x1F514), new Rune(0x266A), new Rune(0x25B4), + new Rune(0x25BE), new Rune(0x25B8), new Rune(0x25C2), - /// The GEM to Unicode character map. - protected override Rune[] CharTable => new[] - { - // 0x00 - new Rune(0x0000), new Rune(0x21E7), new Rune(0x21E9), new Rune(0x21E8), new Rune(0x21E6), new Rune(0x25FC), - new Rune(0x1F5D7), new Rune(0x25C6), + // 0x10 + new Rune(0x25BA), new Rune(0x25C4), new Rune(0x29D3), new Rune(0x2582), new Rune(0x00B6), new Rune(0x00A7), + new Rune(0x2195), new Rune(0x21A8), - // 0x08 - new Rune(0x2713), new Rune(0x1F552), new Rune(0x1F514), new Rune(0x266A), new Rune(0x25B4), - new Rune(0x25BE), new Rune(0x25B8), new Rune(0x25C2), + // 0x18 + new Rune(0x2191), new Rune(0x2193), new Rune(0x2192), new Rune(0x2190), new Rune(0x221F), new Rune(0x2194), + new Rune(0x25B2), new Rune(0x25BC), - // 0x10 - new Rune(0x25BA), new Rune(0x25C4), new Rune(0x29D3), new Rune(0x2582), new Rune(0x00B6), new Rune(0x00A7), - new Rune(0x2195), new Rune(0x21A8), + // 0x20 + new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), + new Rune(0x0026), new Rune(0x0027), - // 0x18 - new Rune(0x2191), new Rune(0x2193), new Rune(0x2192), new Rune(0x2190), new Rune(0x221F), new Rune(0x2194), - new Rune(0x25B2), new Rune(0x25BC), + // 0x28 + new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), + new Rune(0x002E), new Rune(0x002F), - // 0x20 - new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), - new Rune(0x0026), new Rune(0x0027), + // 0x30 + new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), + new Rune(0x0036), new Rune(0x0037), - // 0x28 - new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), - new Rune(0x002E), new Rune(0x002F), + // 0x38 + new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), + new Rune(0x003E), new Rune(0x003F), - // 0x30 - new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), - new Rune(0x0036), new Rune(0x0037), + // 0x40 + new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), + new Rune(0x0046), new Rune(0x0047), - // 0x38 - new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), - new Rune(0x003E), new Rune(0x003F), + // 0x48 + new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), + new Rune(0x004E), new Rune(0x004F), - // 0x40 - new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), - new Rune(0x0046), new Rune(0x0047), + // 0x50 + new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), + new Rune(0x0056), new Rune(0x0057), - // 0x48 - new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), - new Rune(0x004E), new Rune(0x004F), + // 0x58 + new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), + new Rune(0x005E), new Rune(0x005F), - // 0x50 - new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), - new Rune(0x0056), new Rune(0x0057), + // 0x60 + new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), + new Rune(0x0066), new Rune(0x0067), - // 0x58 - new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x005C), new Rune(0x005D), - new Rune(0x005E), new Rune(0x005F), + // 0x68 + new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), + new Rune(0x006E), new Rune(0x006F), - // 0x60 - new Rune(0x0060), new Rune(0x0061), new Rune(0x0062), new Rune(0x0063), new Rune(0x0064), new Rune(0x0065), - new Rune(0x0066), new Rune(0x0067), + // 0x70 + new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), + new Rune(0x0076), new Rune(0x0077), - // 0x68 - new Rune(0x0068), new Rune(0x0069), new Rune(0x006A), new Rune(0x006B), new Rune(0x006C), new Rune(0x006D), - new Rune(0x006E), new Rune(0x006F), + // 0x78 + new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), + new Rune(0x007E), new Rune(0x2302), - // 0x70 - new Rune(0x0070), new Rune(0x0071), new Rune(0x0072), new Rune(0x0073), new Rune(0x0074), new Rune(0x0075), - new Rune(0x0076), new Rune(0x0077), + // 0x80 + new Rune(0x00C7), new Rune(0x00FC), new Rune(0x00E9), new Rune(0x00E2), new Rune(0x00E4), new Rune(0x00E0), + new Rune(0x00E5), new Rune(0x00E7), - // 0x78 - new Rune(0x0078), new Rune(0x0079), new Rune(0x007A), new Rune(0x007B), new Rune(0x007C), new Rune(0x007D), - new Rune(0x007E), new Rune(0x2302), + // 0x88 + new Rune(0x00EA), new Rune(0x00EB), new Rune(0x00E8), new Rune(0x00EF), new Rune(0x00EE), new Rune(0x00EC), + new Rune(0x00C4), new Rune(0x00C5), - // 0x80 - new Rune(0x00C7), new Rune(0x00FC), new Rune(0x00E9), new Rune(0x00E2), new Rune(0x00E4), new Rune(0x00E0), - new Rune(0x00E5), new Rune(0x00E7), + // 0x90 + new Rune(0x00C9), new Rune(0x00E6), new Rune(0x00C6), new Rune(0x00F4), new Rune(0x00F6), new Rune(0x00F2), + new Rune(0x00FB), new Rune(0x00F9), - // 0x88 - new Rune(0x00EA), new Rune(0x00EB), new Rune(0x00E8), new Rune(0x00EF), new Rune(0x00EE), new Rune(0x00EC), - new Rune(0x00C4), new Rune(0x00C5), + // 0x98 + new Rune(0x00FF), new Rune(0x00D6), new Rune(0x00DC), new Rune(0x00FB), new Rune(0x00A3), new Rune(0x00D8), + new Rune(0x00A4), new Rune(0x0192), - // 0x90 - new Rune(0x00C9), new Rune(0x00E6), new Rune(0x00C6), new Rune(0x00F4), new Rune(0x00F6), new Rune(0x00F2), - new Rune(0x00FB), new Rune(0x00F9), + // 0xA0 + new Rune(0x00E1), new Rune(0x00ED), new Rune(0x00F3), new Rune(0x00FA), new Rune(0x00F1), new Rune(0x00D1), + new Rune(0x00AA), new Rune(0x00BA), - // 0x98 - new Rune(0x00FF), new Rune(0x00D6), new Rune(0x00DC), new Rune(0x00FB), new Rune(0x00A3), new Rune(0x00D8), - new Rune(0x00A4), new Rune(0x0192), + // 0xA8 + new Rune(0x00BF), new Rune(0x201C), new Rune(0x201D), new Rune(0x2039), new Rune(0x203A), new Rune(0x00A1), + new Rune(0x00AB), new Rune(0x00BB), - // 0xA0 - new Rune(0x00E1), new Rune(0x00ED), new Rune(0x00F3), new Rune(0x00FA), new Rune(0x00F1), new Rune(0x00D1), - new Rune(0x00AA), new Rune(0x00BA), + // 0xB0 + new Rune(0x00E3), new Rune(0x00F5), new Rune(0x00A5), new Rune(0x00A2), new Rune(0x0153), new Rune(0x0152), + new Rune(0x00C0), new Rune(0x00C3), - // 0xA8 - new Rune(0x00BF), new Rune(0x201C), new Rune(0x201D), new Rune(0x2039), new Rune(0x203A), new Rune(0x00A1), - new Rune(0x00AB), new Rune(0x00BB), + // 0xB8 + new Rune(0x00D5), new Rune(0x00A7), new Rune(0x2021), new Rune(0x2020), new Rune(0x00B6), new Rune(0x00A9), + new Rune(0x00AE), new Rune(0x2122), - // 0xB0 - new Rune(0x00E3), new Rune(0x00F5), new Rune(0x00A5), new Rune(0x00A2), new Rune(0x0153), new Rune(0x0152), - new Rune(0x00C0), new Rune(0x00C3), + // 0xC0 + new Rune(0x201E), new Rune(0x2026), new Rune(0x2030), new Rune(0x2022), new Rune(0x2013), new Rune(0x2014), + new Rune(0x2070), new Rune(0x00C1), - // 0xB8 - new Rune(0x00D5), new Rune(0x00A7), new Rune(0x2021), new Rune(0x2020), new Rune(0x00B6), new Rune(0x00A9), - new Rune(0x00AE), new Rune(0x2122), + // 0xC8 + new Rune(0x00C2), new Rune(0x00C8), new Rune(0x00CA), new Rune(0x00CB), new Rune(0x00CC), new Rune(0x00CD), + new Rune(0x00CE), new Rune(0x00CF), - // 0xC0 - new Rune(0x201E), new Rune(0x2026), new Rune(0x2030), new Rune(0x2022), new Rune(0x2013), new Rune(0x2014), - new Rune(0x2070), new Rune(0x00C1), + // 0xD0 + new Rune(0x00D2), new Rune(0x00D3), new Rune(0x00D4), new Rune(0x0160), new Rune(0x0161), new Rune(0x00D9), + new Rune(0x00DA), new Rune(0x00DB), - // 0xC8 - new Rune(0x00C2), new Rune(0x00C8), new Rune(0x00CA), new Rune(0x00CB), new Rune(0x00CC), new Rune(0x00CD), - new Rune(0x00CE), new Rune(0x00CF), + // 0xD8 + new Rune(0x0178), new Rune(0x00DF), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0xD0 - new Rune(0x00D2), new Rune(0x00D3), new Rune(0x00D4), new Rune(0x0160), new Rune(0x0161), new Rune(0x00D9), - new Rune(0x00DA), new Rune(0x00DB), + // 0xE0 + new Rune(0x03B1), new Rune(0x03B2), new Rune(0x0393), new Rune(0x03C0), new Rune(0x03A3), new Rune(0x03C3), + new Rune(0x00B5), new Rune(0x03C4), - // 0xD8 - new Rune(0x0178), new Rune(0x00DF), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xE8 + new Rune(0x03A6), new Rune(0x0398), new Rune(0x03A9), new Rune(0x03B4), new Rune(0x222E), new Rune(0x0278), + new Rune(0x2208), new Rune(0x2229), - // 0xE0 - new Rune(0x03B1), new Rune(0x03B2), new Rune(0x0393), new Rune(0x03C0), new Rune(0x03A3), new Rune(0x03C3), - new Rune(0x00B5), new Rune(0x03C4), + // 0xF0 + new Rune(0x2261), new Rune(0x00B1), new Rune(0x2265), new Rune(0x2264), new Rune(0x2320), new Rune(0x2321), + new Rune(0x00F7), new Rune(0x2248), - // 0xE8 - new Rune(0x03A6), new Rune(0x0398), new Rune(0x03A9), new Rune(0x03B4), new Rune(0x222E), new Rune(0x0278), - new Rune(0x2208), new Rune(0x2229), + // 0xF8 + new Rune(0x00B0), new Rune(0x2219), new Rune(0x00B7), new Rune(0x221A), new Rune(0x207F), new Rune(0x00B2), + new Rune(0x25A0), new Rune(0x2205) + }; - // 0xF0 - new Rune(0x2261), new Rune(0x00B1), new Rune(0x2265), new Rune(0x2264), new Rune(0x2320), new Rune(0x2321), - new Rune(0x00F7), new Rune(0x2248), - - // 0xF8 - new Rune(0x00B0), new Rune(0x2219), new Rune(0x00B7), new Rune(0x221A), new Rune(0x207F), new Rune(0x00B2), - new Rune(0x25A0), new Rune(0x2205) - }; - - /// Converts a Unicode character to an GEM character - /// GEM character. - /// Unicode character. - private protected override byte GetByte(Rune character) => character.Value switch - { - 0x0000 => 0x00, - 0x21E7 => 0x01, - 0x21E9 => 0x02, - 0x21E8 => 0x03, - 0x21E6 => 0x04, - 0x25FC => 0x05, - 0x1F5D7 => 0x06, - 0x25C6 => 0x07, - 0x2713 => 0x08, - 0x1F552 => 0x09, - 0x1F514 => 0x0A, - 0x266A => 0x0B, - 0x25B4 => 0x0C, - 0x25BE => 0x0D, - 0x25B8 => 0x0E, - 0x25C2 => 0x0F, - 0x25BA => 0x10, - 0x25C4 => 0x11, - 0x29D3 => 0x12, - 0x2582 => 0x13, - 0x2195 => 0x16, - 0x21A8 => 0x17, - 0x2191 => 0x18, - 0x2193 => 0x19, - 0x2192 => 0x1A, - 0x2190 => 0x1B, - 0x221F => 0x1C, - 0x2194 => 0x1D, - 0x25B2 => 0x1E, - 0x25BC => 0x1F, - 0x0020 => 0x20, - 0x0021 => 0x21, - 0x0022 => 0x22, - 0x0023 => 0x23, - 0x0024 => 0x24, - 0x0025 => 0x25, - 0x0026 => 0x26, - 0x0027 => 0x27, - 0x0028 => 0x28, - 0x0029 => 0x29, - 0x002A => 0x2A, - 0x002B => 0x2B, - 0x002C => 0x2C, - 0x002D => 0x2D, - 0x002E => 0x2E, - 0x002F => 0x2F, - 0x0030 => 0x30, - 0x0031 => 0x31, - 0x0032 => 0x32, - 0x0033 => 0x33, - 0x0034 => 0x34, - 0x0035 => 0x35, - 0x0036 => 0x36, - 0x0037 => 0x37, - 0x0038 => 0x38, - 0x0039 => 0x39, - 0x003A => 0x3A, - 0x003B => 0x3B, - 0x003C => 0x3C, - 0x003D => 0x3D, - 0x003E => 0x3E, - 0x003F => 0x3F, - 0x0040 => 0x40, - 0x0041 => 0x41, - 0x0042 => 0x42, - 0x0043 => 0x43, - 0x0044 => 0x44, - 0x0045 => 0x45, - 0x0046 => 0x46, - 0x0047 => 0x47, - 0x0048 => 0x48, - 0x0049 => 0x49, - 0x004A => 0x4A, - 0x004B => 0x4B, - 0x004C => 0x4C, - 0x004D => 0x4D, - 0x004E => 0x4E, - 0x004F => 0x4F, - 0x0050 => 0x50, - 0x0051 => 0x51, - 0x0052 => 0x52, - 0x0053 => 0x53, - 0x0054 => 0x54, - 0x0055 => 0x55, - 0x0056 => 0x56, - 0x0057 => 0x57, - 0x0058 => 0x58, - 0x0059 => 0x59, - 0x005A => 0x5A, - 0x005B => 0x5B, - 0x005C => 0x5C, - 0x005D => 0x5D, - 0x005E => 0x5E, - 0x005F => 0x5F, - 0x0060 => 0x60, - 0x0061 => 0x61, - 0x0062 => 0x62, - 0x0063 => 0x63, - 0x0064 => 0x64, - 0x0065 => 0x65, - 0x0066 => 0x66, - 0x0067 => 0x67, - 0x0068 => 0x68, - 0x0069 => 0x69, - 0x006A => 0x6A, - 0x006B => 0x6B, - 0x006C => 0x6C, - 0x006D => 0x6D, - 0x006E => 0x6E, - 0x006F => 0x6F, - 0x0070 => 0x70, - 0x0071 => 0x71, - 0x0072 => 0x72, - 0x0073 => 0x73, - 0x0074 => 0x74, - 0x0075 => 0x75, - 0x0076 => 0x76, - 0x0077 => 0x77, - 0x0078 => 0x78, - 0x0079 => 0x79, - 0x007A => 0x7A, - 0x007B => 0x7B, - 0x007C => 0x7C, - 0x007D => 0x7D, - 0x007E => 0x7E, - 0x2302 => 0x7F, - 0x00C7 => 0x80, - 0x00FC => 0x81, - 0x00E9 => 0x82, - 0x00E2 => 0x83, - 0x00E4 => 0x84, - 0x00E0 => 0x85, - 0x00E5 => 0x86, - 0x00E7 => 0x87, - 0x00EA => 0x88, - 0x00EB => 0x89, - 0x00E8 => 0x8A, - 0x00EF => 0x8B, - 0x00EE => 0x8C, - 0x00EC => 0x8D, - 0x00C4 => 0x8E, - 0x00C5 => 0x8F, - 0x00C9 => 0x90, - 0x00E6 => 0x91, - 0x00C6 => 0x92, - 0x00F4 => 0x93, - 0x00F6 => 0x94, - 0x00F2 => 0x95, - 0x00FB => 0x96, - 0x00F9 => 0x97, - 0x00FF => 0x98, - 0x00D6 => 0x99, - 0x00DC => 0x9A, - 0x00F8 => 0x9B, - 0x00A3 => 0x9C, - 0x00D8 => 0x9D, - 0x00A4 => 0x9E, - 0x0192 => 0x9F, - 0x00E1 => 0xA0, - 0x00ED => 0xA1, - 0x00F3 => 0xA2, - 0x00FA => 0xA3, - 0x00F1 => 0xA4, - 0x00D1 => 0xA5, - 0x00AA => 0xA6, - 0x00BA => 0xA7, - 0x00BF => 0xA8, - 0x201C => 0xA9, - 0x201D => 0xAA, - 0x2039 => 0xAB, - 0x203A => 0xAC, - 0x00A1 => 0xAD, - 0x00AB => 0xAE, - 0x00BB => 0xAF, - 0x00E3 => 0xB0, - 0x00F5 => 0xB1, - 0x00A5 => 0xB2, - 0x00A2 => 0xB3, - 0x0153 => 0xB4, - 0x0152 => 0xB5, - 0x00C0 => 0xB6, - 0x00C3 => 0xB7, - 0x00D5 => 0xB8, - 0x00A7 => 0xB9, - 0x2821 => 0xBA, - 0x2020 => 0xBB, - 0x00B6 => 0xBC, - 0x00A9 => 0xBD, - 0x00AE => 0xBE, - 0x2122 => 0xBF, - 0x201E => 0xC0, - 0x2026 => 0xC1, - 0x2030 => 0xC2, - 0x2022 => 0xC3, - 0x2013 => 0xC4, - 0x2014 => 0xC5, - 0x2070 => 0xC6, - 0x00C1 => 0xC7, - 0x00C2 => 0xC8, - 0x00C8 => 0xC9, - 0x00CA => 0xCA, - 0x00CB => 0xCB, - 0x00CC => 0xCC, - 0x00CD => 0xCD, - 0x00CE => 0xCE, - 0x00CF => 0xCF, - 0x00D2 => 0xD0, - 0x00D3 => 0xD1, - 0x00D4 => 0xD2, - 0x0160 => 0xD3, - 0x0161 => 0xD4, - 0x00D9 => 0xD5, - 0x00DA => 0xD6, - 0x00DB => 0xD7, - 0x0178 => 0xD8, - 0x00DF => 0xD9, - 0x03B1 => 0xE0, - 0x03B2 => 0xE1, - 0x0393 => 0xE2, - 0x03C0 => 0xE3, - 0x03A3 => 0xE4, - 0x03C3 => 0xE5, - 0x00B5 => 0xE6, - 0x03C4 => 0xE7, - 0x03A6 => 0xE8, - 0x0398 => 0xE9, - 0x03A9 => 0xEA, - 0x03B4 => 0xEB, - 0x222E => 0xEC, - 0x0278 => 0xED, - 0x2208 => 0xEE, - 0x2229 => 0xEF, - 0x2261 => 0xF0, - 0x00B1 => 0xF1, - 0x2265 => 0xF2, - 0x2264 => 0xF3, - 0x2320 => 0xF4, - 0x2321 => 0xF5, - 0x00F7 => 0xF6, - 0x2248 => 0xF7, - 0x00B0 => 0xF8, - 0x2219 => 0xF9, - 0x00B7 => 0xFA, - 0x221A => 0xFB, - 0x207F => 0xFC, - 0x00B2 => 0xFD, - 0x25A0 => 0xFE, - 0x2205 => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an GEM character + /// GEM character. + /// Unicode character. + private protected override byte GetByte(Rune character) => character.Value switch + { + 0x0000 => 0x00, + 0x21E7 => 0x01, + 0x21E9 => 0x02, + 0x21E8 => 0x03, + 0x21E6 => 0x04, + 0x25FC => 0x05, + 0x1F5D7 => 0x06, + 0x25C6 => 0x07, + 0x2713 => 0x08, + 0x1F552 => 0x09, + 0x1F514 => 0x0A, + 0x266A => 0x0B, + 0x25B4 => 0x0C, + 0x25BE => 0x0D, + 0x25B8 => 0x0E, + 0x25C2 => 0x0F, + 0x25BA => 0x10, + 0x25C4 => 0x11, + 0x29D3 => 0x12, + 0x2582 => 0x13, + 0x2195 => 0x16, + 0x21A8 => 0x17, + 0x2191 => 0x18, + 0x2193 => 0x19, + 0x2192 => 0x1A, + 0x2190 => 0x1B, + 0x221F => 0x1C, + 0x2194 => 0x1D, + 0x25B2 => 0x1E, + 0x25BC => 0x1F, + 0x0020 => 0x20, + 0x0021 => 0x21, + 0x0022 => 0x22, + 0x0023 => 0x23, + 0x0024 => 0x24, + 0x0025 => 0x25, + 0x0026 => 0x26, + 0x0027 => 0x27, + 0x0028 => 0x28, + 0x0029 => 0x29, + 0x002A => 0x2A, + 0x002B => 0x2B, + 0x002C => 0x2C, + 0x002D => 0x2D, + 0x002E => 0x2E, + 0x002F => 0x2F, + 0x0030 => 0x30, + 0x0031 => 0x31, + 0x0032 => 0x32, + 0x0033 => 0x33, + 0x0034 => 0x34, + 0x0035 => 0x35, + 0x0036 => 0x36, + 0x0037 => 0x37, + 0x0038 => 0x38, + 0x0039 => 0x39, + 0x003A => 0x3A, + 0x003B => 0x3B, + 0x003C => 0x3C, + 0x003D => 0x3D, + 0x003E => 0x3E, + 0x003F => 0x3F, + 0x0040 => 0x40, + 0x0041 => 0x41, + 0x0042 => 0x42, + 0x0043 => 0x43, + 0x0044 => 0x44, + 0x0045 => 0x45, + 0x0046 => 0x46, + 0x0047 => 0x47, + 0x0048 => 0x48, + 0x0049 => 0x49, + 0x004A => 0x4A, + 0x004B => 0x4B, + 0x004C => 0x4C, + 0x004D => 0x4D, + 0x004E => 0x4E, + 0x004F => 0x4F, + 0x0050 => 0x50, + 0x0051 => 0x51, + 0x0052 => 0x52, + 0x0053 => 0x53, + 0x0054 => 0x54, + 0x0055 => 0x55, + 0x0056 => 0x56, + 0x0057 => 0x57, + 0x0058 => 0x58, + 0x0059 => 0x59, + 0x005A => 0x5A, + 0x005B => 0x5B, + 0x005C => 0x5C, + 0x005D => 0x5D, + 0x005E => 0x5E, + 0x005F => 0x5F, + 0x0060 => 0x60, + 0x0061 => 0x61, + 0x0062 => 0x62, + 0x0063 => 0x63, + 0x0064 => 0x64, + 0x0065 => 0x65, + 0x0066 => 0x66, + 0x0067 => 0x67, + 0x0068 => 0x68, + 0x0069 => 0x69, + 0x006A => 0x6A, + 0x006B => 0x6B, + 0x006C => 0x6C, + 0x006D => 0x6D, + 0x006E => 0x6E, + 0x006F => 0x6F, + 0x0070 => 0x70, + 0x0071 => 0x71, + 0x0072 => 0x72, + 0x0073 => 0x73, + 0x0074 => 0x74, + 0x0075 => 0x75, + 0x0076 => 0x76, + 0x0077 => 0x77, + 0x0078 => 0x78, + 0x0079 => 0x79, + 0x007A => 0x7A, + 0x007B => 0x7B, + 0x007C => 0x7C, + 0x007D => 0x7D, + 0x007E => 0x7E, + 0x2302 => 0x7F, + 0x00C7 => 0x80, + 0x00FC => 0x81, + 0x00E9 => 0x82, + 0x00E2 => 0x83, + 0x00E4 => 0x84, + 0x00E0 => 0x85, + 0x00E5 => 0x86, + 0x00E7 => 0x87, + 0x00EA => 0x88, + 0x00EB => 0x89, + 0x00E8 => 0x8A, + 0x00EF => 0x8B, + 0x00EE => 0x8C, + 0x00EC => 0x8D, + 0x00C4 => 0x8E, + 0x00C5 => 0x8F, + 0x00C9 => 0x90, + 0x00E6 => 0x91, + 0x00C6 => 0x92, + 0x00F4 => 0x93, + 0x00F6 => 0x94, + 0x00F2 => 0x95, + 0x00FB => 0x96, + 0x00F9 => 0x97, + 0x00FF => 0x98, + 0x00D6 => 0x99, + 0x00DC => 0x9A, + 0x00F8 => 0x9B, + 0x00A3 => 0x9C, + 0x00D8 => 0x9D, + 0x00A4 => 0x9E, + 0x0192 => 0x9F, + 0x00E1 => 0xA0, + 0x00ED => 0xA1, + 0x00F3 => 0xA2, + 0x00FA => 0xA3, + 0x00F1 => 0xA4, + 0x00D1 => 0xA5, + 0x00AA => 0xA6, + 0x00BA => 0xA7, + 0x00BF => 0xA8, + 0x201C => 0xA9, + 0x201D => 0xAA, + 0x2039 => 0xAB, + 0x203A => 0xAC, + 0x00A1 => 0xAD, + 0x00AB => 0xAE, + 0x00BB => 0xAF, + 0x00E3 => 0xB0, + 0x00F5 => 0xB1, + 0x00A5 => 0xB2, + 0x00A2 => 0xB3, + 0x0153 => 0xB4, + 0x0152 => 0xB5, + 0x00C0 => 0xB6, + 0x00C3 => 0xB7, + 0x00D5 => 0xB8, + 0x00A7 => 0xB9, + 0x2821 => 0xBA, + 0x2020 => 0xBB, + 0x00B6 => 0xBC, + 0x00A9 => 0xBD, + 0x00AE => 0xBE, + 0x2122 => 0xBF, + 0x201E => 0xC0, + 0x2026 => 0xC1, + 0x2030 => 0xC2, + 0x2022 => 0xC3, + 0x2013 => 0xC4, + 0x2014 => 0xC5, + 0x2070 => 0xC6, + 0x00C1 => 0xC7, + 0x00C2 => 0xC8, + 0x00C8 => 0xC9, + 0x00CA => 0xCA, + 0x00CB => 0xCB, + 0x00CC => 0xCC, + 0x00CD => 0xCD, + 0x00CE => 0xCE, + 0x00CF => 0xCF, + 0x00D2 => 0xD0, + 0x00D3 => 0xD1, + 0x00D4 => 0xD2, + 0x0160 => 0xD3, + 0x0161 => 0xD4, + 0x00D9 => 0xD5, + 0x00DA => 0xD6, + 0x00DB => 0xD7, + 0x0178 => 0xD8, + 0x00DF => 0xD9, + 0x03B1 => 0xE0, + 0x03B2 => 0xE1, + 0x0393 => 0xE2, + 0x03C0 => 0xE3, + 0x03A3 => 0xE4, + 0x03C3 => 0xE5, + 0x00B5 => 0xE6, + 0x03C4 => 0xE7, + 0x03A6 => 0xE8, + 0x0398 => 0xE9, + 0x03A9 => 0xEA, + 0x03B4 => 0xEB, + 0x222E => 0xEC, + 0x0278 => 0xED, + 0x2208 => 0xEE, + 0x2229 => 0xEF, + 0x2261 => 0xF0, + 0x00B1 => 0xF1, + 0x2265 => 0xF2, + 0x2264 => 0xF3, + 0x2320 => 0xF4, + 0x2321 => 0xF5, + 0x00F7 => 0xF6, + 0x2248 => 0xF7, + 0x00B0 => 0xF8, + 0x2219 => 0xF9, + 0x00B7 => 0xFA, + 0x221A => 0xFB, + 0x207F => 0xFC, + 0x00B2 => 0xFD, + 0x25A0 => 0xFE, + 0x2205 => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/GEOS.cs b/Claunia.Encoding/GEOS.cs index f8433f4..0e9a840 100644 --- a/Claunia.Encoding/GEOS.cs +++ b/Claunia.Encoding/GEOS.cs @@ -24,386 +24,385 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an GEOS character encoding of Unicode characters. +public class GEOS : SingleByteEncoding { - /// Represents an GEOS character encoding of Unicode characters. - public class GEOS : SingleByteEncoding + /// + public override string BodyName => "geos"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Western European (GEOS)"; + /// + public override string HeaderName => "geos"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => true; + + /// + /// The GEOS to Unicode character map. In the GEOS character map application lots of positions appears as '\u002E' + /// ('.' period) in normal (non-symbol) fonts. + /// + protected override char[] CharTable => new[] { - /// - public override string BodyName => "geos"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Western European (GEOS)"; - /// - public override string HeaderName => "geos"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// - /// The GEOS to Unicode character map. In the GEOS character map application lots of positions appears as '\u002E' - /// ('.' period) in normal (non-symbol) fonts. - /// - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', - // 0x80 - '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', + // 0x90 + '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', - // 0x88 - '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', + // 0x98 + '\u00F2', '\u00F4', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', '\u2020', - // 0x90 - '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', + // 0xA0 + '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u00B7', '\u00B6', '\u00DF', '\u00AE', - // 0x98 - '\u00F2', '\u00F4', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', '\u2020', + // 0xA8 + '\u00A9', '\u2122', '\u0022', '\u0027', '\u002E', '\u00C6', '\u00D8', '\u221E', - // 0xA0 - '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u00B7', '\u00B6', '\u00DF', '\u00AE', + // 0xB0 + '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u002E', '\u002E', '\u002E', - // 0xA8 - '\u00A9', '\u2122', '\u0022', '\u0027', '\u002E', '\u00C6', '\u00D8', '\u221E', + // 0xB8 + '\u03C0', '\u002E', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8', '\u00BF', - // 0xB0 - '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u002E', '\u002E', '\u002E', + // 0xC0 + '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u002E', '\u00AB', '\u00BB', - // 0xB8 - '\u03C0', '\u002E', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8', '\u00BF', + // 0xC8 + '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', '\u2013', - // 0xC0 - '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u002E', '\u00AB', '\u00BB', + // 0xD0 + '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u002E', '\u00FF', - // 0xC8 - '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', '\u2013', + // 0xD8 + '\u0178', '\u002E', '\u00A4', '\u2039', '\u203A', '\u00FD', '\u00DD', '\u2021', - // 0xD0 - '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u002E', '\u00FF', + // 0xE0 + '\u002E', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1', '\u00CB', - // 0xD8 - '\u0178', '\u002E', '\u00A4', '\u2039', '\u203A', '\u00FD', '\u00DD', '\u2021', + // 0xE8 + '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', '\u002E', - // 0xE0 - '\u002E', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1', '\u00CB', + // 0xF0 + '\u00D2', '\u00DA', '\u00D9', '\u00B9', '\u20C6', '\u20DC', '\u00AF', '\u02C7', - // 0xE8 - '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', '\u002E', + // 0xF8 + '\u00B7', '\u00B0', '\u00B8', '\u2032', '\u02DB', '\u02D8', '\u00A0', '\u002E' + }; - // 0xF0 - '\u00D2', '\u00DA', '\u00D9', '\u00B9', '\u20C6', '\u20DC', '\u00AF', '\u02C7', - - // 0xF8 - '\u00B7', '\u00B0', '\u00B8', '\u2032', '\u02DB', '\u02D8', '\u00A0', '\u002E' - }; - - /// Converts a Unicode character to an GEOS character - /// GEOS character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u0011' => 0x11, - '\u0012' => 0x12, - '\u0013' => 0x13, - '\u0014' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u00C4' => 0x80, - '\u00C5' => 0x81, - '\u00C7' => 0x82, - '\u00C9' => 0x83, - '\u00D1' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u00E1' => 0x87, - '\u00E0' => 0x88, - '\u00E2' => 0x89, - '\u00E4' => 0x8A, - '\u00E3' => 0x8B, - '\u00E5' => 0x8C, - '\u00E7' => 0x8D, - '\u00E9' => 0x8E, - '\u00E8' => 0x8F, - '\u00EA' => 0x90, - '\u00EB' => 0x91, - '\u00ED' => 0x92, - '\u00EC' => 0x93, - '\u00EE' => 0x94, - '\u00EF' => 0x95, - '\u00F1' => 0x96, - '\u00F3' => 0x97, - '\u00F2' => 0x98, - '\u00F4' => 0x99, - '\u00F5' => 0x9A, - '\u00FA' => 0x9B, - '\u00F9' => 0x9C, - '\u00FB' => 0x9D, - '\u00FC' => 0x9E, - '\u2020' => 0x9F, - '\u00B0' => 0xA0, - '\u00A2' => 0xA1, - '\u00A3' => 0xA2, - '\u00A7' => 0xA3, - '\u00B7' => 0xA4, - '\u00B6' => 0xA5, - '\u00DF' => 0xA6, - '\u00AE' => 0xA7, - '\u00A9' => 0xA8, - '\u2122' => 0xA9, - '\u00C6' => 0xAD, - '\u00D8' => 0xAE, - '\u221E' => 0xAF, - '\u00B1' => 0xB0, - '\u2264' => 0xB1, - '\u2265' => 0xB2, - '\u00A5' => 0xB3, - '\u00B5' => 0xB4, - '\u03C0' => 0xB8, - '\u00AA' => 0xBA, - '\u00BA' => 0xBB, - '\u03A9' => 0xBC, - '\u00E6' => 0xBD, - '\u00F8' => 0xBE, - '\u00BF' => 0xBF, - '\u00A1' => 0xC0, - '\u00AC' => 0xC1, - '\u221A' => 0xC2, - '\u0192' => 0xC3, - '\u2248' => 0xC4, - '\u00AB' => 0xC6, - '\u00BB' => 0xC7, - '\u2026' => 0xC8, - '\u00A0' => 0xC9, - '\u00C0' => 0xCA, - '\u00C3' => 0xCB, - '\u00D5' => 0xCC, - '\u0152' => 0xCD, - '\u0153' => 0xCE, - '\u2013' => 0xCF, - '\u2014' => 0xD0, - '\u201C' => 0xD1, - '\u201D' => 0xD2, - '\u2018' => 0xD3, - '\u2019' => 0xD4, - '\u00F7' => 0xD5, - '\u00FF' => 0xD7, - '\u0178' => 0xD8, - '\u05A4' => 0xDA, - '\u2039' => 0xDB, - '\u203A' => 0xDC, - '\u00FD' => 0xDD, - '\u00DD' => 0xDE, - '\u2021' => 0xDF, - '\u201A' => 0xE1, - '\u201E' => 0xE2, - '\u2030' => 0xE3, - '\u00C2' => 0xE4, - '\u00CA' => 0xE5, - '\u00C1' => 0xE6, - '\u00CB' => 0xE7, - '\u00C8' => 0xE8, - '\u00CD' => 0xE9, - '\u00CE' => 0xEA, - '\u00CF' => 0xEB, - '\u00CC' => 0xEC, - '\u00D3' => 0xED, - '\u00D4' => 0xEE, - '\u00D2' => 0xF0, - '\u00DA' => 0xF1, - '\u00D9' => 0xF2, - '\u00B9' => 0xF3, - '\u20C6' => 0xF4, - '\u20DC' => 0xF5, - '\u00AF' => 0xF6, - '\u02C7' => 0xF7, - '\u00B8' => 0xFA, - '\u2032' => 0xFB, - '\u02DB' => 0xFC, - '\u02D8' => 0xFD, - _ => 0x3F - }; - } + /// Converts a Unicode character to an GEOS character + /// GEOS character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u0011' => 0x11, + '\u0012' => 0x12, + '\u0013' => 0x13, + '\u0014' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u00C4' => 0x80, + '\u00C5' => 0x81, + '\u00C7' => 0x82, + '\u00C9' => 0x83, + '\u00D1' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u00E1' => 0x87, + '\u00E0' => 0x88, + '\u00E2' => 0x89, + '\u00E4' => 0x8A, + '\u00E3' => 0x8B, + '\u00E5' => 0x8C, + '\u00E7' => 0x8D, + '\u00E9' => 0x8E, + '\u00E8' => 0x8F, + '\u00EA' => 0x90, + '\u00EB' => 0x91, + '\u00ED' => 0x92, + '\u00EC' => 0x93, + '\u00EE' => 0x94, + '\u00EF' => 0x95, + '\u00F1' => 0x96, + '\u00F3' => 0x97, + '\u00F2' => 0x98, + '\u00F4' => 0x99, + '\u00F5' => 0x9A, + '\u00FA' => 0x9B, + '\u00F9' => 0x9C, + '\u00FB' => 0x9D, + '\u00FC' => 0x9E, + '\u2020' => 0x9F, + '\u00B0' => 0xA0, + '\u00A2' => 0xA1, + '\u00A3' => 0xA2, + '\u00A7' => 0xA3, + '\u00B7' => 0xA4, + '\u00B6' => 0xA5, + '\u00DF' => 0xA6, + '\u00AE' => 0xA7, + '\u00A9' => 0xA8, + '\u2122' => 0xA9, + '\u00C6' => 0xAD, + '\u00D8' => 0xAE, + '\u221E' => 0xAF, + '\u00B1' => 0xB0, + '\u2264' => 0xB1, + '\u2265' => 0xB2, + '\u00A5' => 0xB3, + '\u00B5' => 0xB4, + '\u03C0' => 0xB8, + '\u00AA' => 0xBA, + '\u00BA' => 0xBB, + '\u03A9' => 0xBC, + '\u00E6' => 0xBD, + '\u00F8' => 0xBE, + '\u00BF' => 0xBF, + '\u00A1' => 0xC0, + '\u00AC' => 0xC1, + '\u221A' => 0xC2, + '\u0192' => 0xC3, + '\u2248' => 0xC4, + '\u00AB' => 0xC6, + '\u00BB' => 0xC7, + '\u2026' => 0xC8, + '\u00A0' => 0xC9, + '\u00C0' => 0xCA, + '\u00C3' => 0xCB, + '\u00D5' => 0xCC, + '\u0152' => 0xCD, + '\u0153' => 0xCE, + '\u2013' => 0xCF, + '\u2014' => 0xD0, + '\u201C' => 0xD1, + '\u201D' => 0xD2, + '\u2018' => 0xD3, + '\u2019' => 0xD4, + '\u00F7' => 0xD5, + '\u00FF' => 0xD7, + '\u0178' => 0xD8, + '\u05A4' => 0xDA, + '\u2039' => 0xDB, + '\u203A' => 0xDC, + '\u00FD' => 0xDD, + '\u00DD' => 0xDE, + '\u2021' => 0xDF, + '\u201A' => 0xE1, + '\u201E' => 0xE2, + '\u2030' => 0xE3, + '\u00C2' => 0xE4, + '\u00CA' => 0xE5, + '\u00C1' => 0xE6, + '\u00CB' => 0xE7, + '\u00C8' => 0xE8, + '\u00CD' => 0xE9, + '\u00CE' => 0xEA, + '\u00CF' => 0xEB, + '\u00CC' => 0xEC, + '\u00D3' => 0xED, + '\u00D4' => 0xEE, + '\u00D2' => 0xF0, + '\u00DA' => 0xF1, + '\u00D9' => 0xF2, + '\u00B9' => 0xF3, + '\u20C6' => 0xF4, + '\u20DC' => 0xF5, + '\u00AF' => 0xF6, + '\u02C7' => 0xF7, + '\u00B8' => 0xFA, + '\u2032' => 0xFB, + '\u02DB' => 0xFC, + '\u02D8' => 0xFD, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/LisaRoman.cs b/Claunia.Encoding/LisaRoman.cs index 2f31788..76e83cb 100644 --- a/Claunia.Encoding/LisaRoman.cs +++ b/Claunia.Encoding/LisaRoman.cs @@ -24,360 +24,359 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Apple Lisa character encoding of Unicode characters. +public class LisaRoman : SingleByteEncoding { - /// Represents an Apple Lisa character encoding of Unicode characters. - public class LisaRoman : SingleByteEncoding + /// + public override string BodyName => "lisa"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Western European (Apple Lisa)"; + /// + public override string HeaderName => "lisa"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 10000; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => true; + + /// The Lisa to Unicode character map. MacRoman is a superset of LisaRoman. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "lisa"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Western European (Apple Lisa)"; - /// - public override string HeaderName => "lisa"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 10000; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Lisa to Unicode character map. MacRoman is a superset of LisaRoman. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u2588', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u2588', + // 0x88 + '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', - // 0x80 - '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', + // 0x90 + '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', - // 0x88 - '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', + // 0x98 + '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', - // 0x90 - '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', + // 0xA0 + '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', - // 0x98 - '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', + // 0xA8 + '\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8', - // 0xA0 - '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', + // 0xB0 + '\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211', - // 0xA8 - '\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8', + // 0xB8 + '\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8', - // 0xB0 - '\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211', + // 0xC0 + '\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', - // 0xB8 - '\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8', + // 0xC8 + '\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', - // 0xC0 - '\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', + // 0xD0 + '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', - // 0xC8 - '\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', + // 0xD8 + '\u00FF', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xD0 - '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', + // 0xE0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xD8 - '\u00FF', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xE8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xE0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xF0 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0xE8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0xF8 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' + }; - // 0xF0 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - - // 0xF8 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' - }; - - /// Converts a Unicode character to an LisaRoman character - /// LisaRoman character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u0011' => 0x11, - '\u0012' => 0x12, - '\u0013' => 0x13, - '\u0014' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u2588' => 0x7F, - '\u00C4' => 0x80, - '\u00C5' => 0x81, - '\u00C7' => 0x82, - '\u00C9' => 0x83, - '\u00D1' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u00E1' => 0x87, - '\u00E0' => 0x88, - '\u00E2' => 0x89, - '\u00E4' => 0x8A, - '\u00E3' => 0x8B, - '\u00E5' => 0x8C, - '\u00E7' => 0x8D, - '\u00E9' => 0x8E, - '\u00E8' => 0x8F, - '\u00EA' => 0x90, - '\u00EB' => 0x91, - '\u00ED' => 0x92, - '\u00EC' => 0x93, - '\u00EE' => 0x94, - '\u00EF' => 0x95, - '\u00F1' => 0x96, - '\u00F3' => 0x97, - '\u00F2' => 0x98, - '\u00F4' => 0x99, - '\u00F6' => 0x9A, - '\u00F5' => 0x9B, - '\u00FA' => 0x9C, - '\u00F9' => 0x9D, - '\u00FB' => 0x9E, - '\u00FC' => 0x9F, - '\u2020' => 0xA0, - '\u00B0' => 0xA1, - '\u00A2' => 0xA2, - '\u00A3' => 0xA3, - '\u00A7' => 0xA4, - '\u2022' => 0xA5, - '\u00B6' => 0xA6, - '\u00DF' => 0xA7, - '\u00AE' => 0xA8, - '\u00A9' => 0xA9, - '\u2122' => 0xAA, - '\u00B4' => 0xAB, - '\u00A8' => 0xAC, - '\u2260' => 0xAD, - '\u00C6' => 0xAE, - '\u00D8' => 0xAF, - '\u221E' => 0xB0, - '\u00B1' => 0xB1, - '\u2264' => 0xB2, - '\u2265' => 0xB3, - '\u00A5' => 0xB4, - '\u00B5' => 0xB5, - '\u2202' => 0xB6, - '\u2211' => 0xB7, - '\u220F' => 0xB8, - '\u03C0' => 0xB9, - '\u222B' => 0xBA, - '\u00AA' => 0xBB, - '\u00BA' => 0xBC, - '\u03A9' => 0xBD, - '\u00E6' => 0xBE, - '\u00F8' => 0xBF, - '\u00BF' => 0xC0, - '\u00A1' => 0xC1, - '\u00AC' => 0xC2, - '\u221A' => 0xC3, - '\u0192' => 0xC4, - '\u2248' => 0xC5, - '\u2206' => 0xC6, - '\u00AB' => 0xC7, - '\u00BB' => 0xC8, - '\u2026' => 0xC9, - '\u00A0' => 0xCA, - '\u00C0' => 0xCB, - '\u00C3' => 0xCC, - '\u00D5' => 0xCD, - '\u0152' => 0xCE, - '\u0153' => 0xCF, - '\u2013' => 0xD0, - '\u2014' => 0xD1, - '\u201C' => 0xD2, - '\u201D' => 0xD3, - '\u2018' => 0xD4, - '\u2019' => 0xD5, - '\u00F7' => 0xD6, - '\u25CA' => 0xD7, - '\u00FF' => 0xD8, - _ => 0x3F - }; - } + /// Converts a Unicode character to an LisaRoman character + /// LisaRoman character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u0011' => 0x11, + '\u0012' => 0x12, + '\u0013' => 0x13, + '\u0014' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u2588' => 0x7F, + '\u00C4' => 0x80, + '\u00C5' => 0x81, + '\u00C7' => 0x82, + '\u00C9' => 0x83, + '\u00D1' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u00E1' => 0x87, + '\u00E0' => 0x88, + '\u00E2' => 0x89, + '\u00E4' => 0x8A, + '\u00E3' => 0x8B, + '\u00E5' => 0x8C, + '\u00E7' => 0x8D, + '\u00E9' => 0x8E, + '\u00E8' => 0x8F, + '\u00EA' => 0x90, + '\u00EB' => 0x91, + '\u00ED' => 0x92, + '\u00EC' => 0x93, + '\u00EE' => 0x94, + '\u00EF' => 0x95, + '\u00F1' => 0x96, + '\u00F3' => 0x97, + '\u00F2' => 0x98, + '\u00F4' => 0x99, + '\u00F6' => 0x9A, + '\u00F5' => 0x9B, + '\u00FA' => 0x9C, + '\u00F9' => 0x9D, + '\u00FB' => 0x9E, + '\u00FC' => 0x9F, + '\u2020' => 0xA0, + '\u00B0' => 0xA1, + '\u00A2' => 0xA2, + '\u00A3' => 0xA3, + '\u00A7' => 0xA4, + '\u2022' => 0xA5, + '\u00B6' => 0xA6, + '\u00DF' => 0xA7, + '\u00AE' => 0xA8, + '\u00A9' => 0xA9, + '\u2122' => 0xAA, + '\u00B4' => 0xAB, + '\u00A8' => 0xAC, + '\u2260' => 0xAD, + '\u00C6' => 0xAE, + '\u00D8' => 0xAF, + '\u221E' => 0xB0, + '\u00B1' => 0xB1, + '\u2264' => 0xB2, + '\u2265' => 0xB3, + '\u00A5' => 0xB4, + '\u00B5' => 0xB5, + '\u2202' => 0xB6, + '\u2211' => 0xB7, + '\u220F' => 0xB8, + '\u03C0' => 0xB9, + '\u222B' => 0xBA, + '\u00AA' => 0xBB, + '\u00BA' => 0xBC, + '\u03A9' => 0xBD, + '\u00E6' => 0xBE, + '\u00F8' => 0xBF, + '\u00BF' => 0xC0, + '\u00A1' => 0xC1, + '\u00AC' => 0xC2, + '\u221A' => 0xC3, + '\u0192' => 0xC4, + '\u2248' => 0xC5, + '\u2206' => 0xC6, + '\u00AB' => 0xC7, + '\u00BB' => 0xC8, + '\u2026' => 0xC9, + '\u00A0' => 0xCA, + '\u00C0' => 0xCB, + '\u00C3' => 0xCC, + '\u00D5' => 0xCD, + '\u0152' => 0xCE, + '\u0153' => 0xCF, + '\u2013' => 0xD0, + '\u2014' => 0xD1, + '\u201C' => 0xD2, + '\u201D' => 0xD3, + '\u2018' => 0xD4, + '\u2019' => 0xD5, + '\u00F7' => 0xD6, + '\u25CA' => 0xD7, + '\u00FF' => 0xD8, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacArabic.cs b/Claunia.Encoding/MacArabic.cs index 5ada828..43db7bc 100644 --- a/Claunia.Encoding/MacArabic.cs +++ b/Claunia.Encoding/MacArabic.cs @@ -24,376 +24,375 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Mac Arabic character encoding of Unicode characters. +public class MacArabic : SingleByteEncoding { - /// Represents an Mac Arabic character encoding of Unicode characters. - public class MacArabic : SingleByteEncoding + /// + public override string BodyName => "x-mac-arabic"; + /// + public override int CodePage => 10004; + /// + public override string EncodingName => "Arabic (Mac)"; + /// + public override string HeaderName => "x-mac-arabic"; + /// + public override string WebName => "x-mac-arabic"; + /// + public override int WindowsCodePage => 10004; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Macintosh Arabic to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "x-mac-arabic"; - /// - public override int CodePage => 10004; - /// - public override string EncodingName => "Arabic (Mac)"; - /// - public override string HeaderName => "x-mac-arabic"; - /// - public override string WebName => "x-mac-arabic"; - /// - public override int WindowsCodePage => 10004; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Macintosh Arabic to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u00C4', '\u00A0', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u00E0', '\u00E2', '\u00E4', '\u06BA', '\u00AB', '\u00E7', '\u00E9', '\u00E8', - // 0x80 - '\u00C4', '\u00A0', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', + // 0x90 + '\u00EA', '\u00EB', '\u00ED', '\u2026', '\u00EE', '\u00EF', '\u00F1', '\u00F3', - // 0x88 - '\u00E0', '\u00E2', '\u00E4', '\u06BA', '\u00AB', '\u00E7', '\u00E9', '\u00E8', + // 0x98 + '\u00BB', '\u00F4', '\u00F6', '\u00F7', '\u00FA', '\u00F9', '\u00FB', '\u00FC', - // 0x90 - '\u00EA', '\u00EB', '\u00ED', '\u2026', '\u00EE', '\u00EF', '\u00F1', '\u00F3', + // 0xA0 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u066A', '\u0026', '\u0027', - // 0x98 - '\u00BB', '\u00F4', '\u00F6', '\u00F7', '\u00FA', '\u00F9', '\u00FB', '\u00FC', + // 0xA8 + '\u0028', '\u0029', '\u002A', '\u002B', '\u060C', '\u002D', '\u002E', '\u002F', - // 0xA0 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u066A', '\u0026', '\u0027', + // 0xB0 + '\u0660', '\u0661', '\u0662', '\u0663', '\u0664', '\u0665', '\u0666', '\u0667', - // 0xA8 - '\u0028', '\u0029', '\u002A', '\u002B', '\u060C', '\u002D', '\u002E', '\u002F', + // 0xB8 + '\u0668', '\u0669', '\u003A', '\u061B', '\u003C', '\u003D', '\u003E', '\u061F', - // 0xB0 - '\u0660', '\u0661', '\u0662', '\u0663', '\u0664', '\u0665', '\u0666', '\u0667', + // 0xC0 + '\u274A', '\u0621', '\u0622', '\u0623', '\u0624', '\u0625', '\u0626', '\u0627', - // 0xB8 - '\u0668', '\u0669', '\u003A', '\u061B', '\u003C', '\u003D', '\u003E', '\u061F', + // 0xC8 + '\u0628', '\u0629', '\u062A', '\u062B', '\u062C', '\u062D', '\u062E', '\u062F', - // 0xC0 - '\u274A', '\u0621', '\u0622', '\u0623', '\u0624', '\u0625', '\u0626', '\u0627', + // 0xD0 + '\u0630', '\u0631', '\u0632', '\u0633', '\u0634', '\u0635', '\u0636', '\u0637', - // 0xC8 - '\u0628', '\u0629', '\u062A', '\u062B', '\u062C', '\u062D', '\u062E', '\u062F', + // 0xD8 + '\u0638', '\u0639', '\u063A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0xD0 - '\u0630', '\u0631', '\u0632', '\u0633', '\u0634', '\u0635', '\u0636', '\u0637', + // 0xE0 + '\u0640', '\u0641', '\u0642', '\u0643', '\u0644', '\u0645', '\u0646', '\u0647', - // 0xD8 - '\u0638', '\u0639', '\u063A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0xE8 + '\u0648', '\u0649', '\u064A', '\u064B', '\u064C', '\u064D', '\u064E', '\u064F', - // 0xE0 - '\u0640', '\u0641', '\u0642', '\u0643', '\u0644', '\u0645', '\u0646', '\u0647', + // 0xF0 + '\u0650', '\u0651', '\u0652', '\u067E', '\u0679', '\u0686', '\u06D5', '\u06A4', - // 0xE8 - '\u0648', '\u0649', '\u064A', '\u064B', '\u064C', '\u064D', '\u064E', '\u064F', + // 0xF8 + '\u06AF', '\u0688', '\u0691', '\u007B', '\u007C', '\u007D', '\u0698', '\u06D2' + }; - // 0xF0 - '\u0650', '\u0651', '\u0652', '\u067E', '\u0679', '\u0686', '\u06D5', '\u06A4', - - // 0xF8 - '\u06AF', '\u0688', '\u0691', '\u007B', '\u007C', '\u007D', '\u0698', '\u06D2' - }; - - /// Converts a Unicode character to an Mac Arabic character - /// Mac Arabic character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\u0014' => 0x14, - '\uF8FF' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u00C4' => 0x80, - '\u00A0' => 0x81, - '\u00C7' => 0x82, - '\u00C9' => 0x83, - '\u00D1' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u00E1' => 0x87, - '\u00E0' => 0x88, - '\u00E2' => 0x89, - '\u00E4' => 0x8A, - '\u06BA' => 0x8B, - '\u00AB' => 0x8C, - '\u00E7' => 0x8D, - '\u00E9' => 0x8E, - '\u00E8' => 0x8F, - '\u00EA' => 0x90, - '\u00EB' => 0x91, - '\u00ED' => 0x92, - '\u2026' => 0x93, - '\u00EE' => 0x94, - '\u00EF' => 0x95, - '\u00F1' => 0x96, - '\u00F3' => 0x97, - '\u00BB' => 0x98, - '\u00F4' => 0x99, - '\u00F6' => 0x9A, - '\u00F7' => 0x9B, - '\u00FA' => 0x9C, - '\u00F9' => 0x9D, - '\u00FB' => 0x9E, - '\u00FC' => 0x9F, - '\u066A' => 0xA5, - '\u060C' => 0xAC, - '\u0660' => 0xB0, - '\u0661' => 0xB1, - '\u0662' => 0xB2, - '\u0663' => 0xB3, - '\u0664' => 0xB4, - '\u0665' => 0xB5, - '\u0666' => 0xB6, - '\u0667' => 0xB7, - '\u0668' => 0xB8, - '\u0669' => 0xB9, - '\u061B' => 0xBB, - '\u061F' => 0xBF, - '\u274A' => 0xC0, - '\u0621' => 0xC1, - '\u0622' => 0xC2, - '\u0623' => 0xC3, - '\u0624' => 0xC4, - '\u0625' => 0xC5, - '\u0626' => 0xC6, - '\u0627' => 0xC7, - '\u0628' => 0xC8, - '\u0629' => 0xC9, - '\u062A' => 0xCA, - '\u062B' => 0xCB, - '\u062C' => 0xCC, - '\u062D' => 0xCD, - '\u062E' => 0xCE, - '\u062F' => 0xCF, - '\u0630' => 0xD0, - '\u0631' => 0xD1, - '\u0632' => 0xD2, - '\u0633' => 0xD3, - '\u0634' => 0xD4, - '\u0635' => 0xD5, - '\u0636' => 0xD6, - '\u0637' => 0xD7, - '\u0638' => 0xD8, - '\u0639' => 0xD9, - '\u063A' => 0xDA, - '\u0640' => 0xE0, - '\u0641' => 0xE1, - '\u0642' => 0xE2, - '\u0643' => 0xE3, - '\u0644' => 0xE4, - '\u0645' => 0xE5, - '\u0646' => 0xE6, - '\u0647' => 0xE7, - '\u0648' => 0xE8, - '\u0649' => 0xE9, - '\u064A' => 0xEA, - '\u064B' => 0xEB, - '\u064C' => 0xEC, - '\u064D' => 0xED, - '\u064E' => 0xEE, - '\u064F' => 0xEF, - '\u0650' => 0xF0, - '\u0651' => 0xF1, - '\u0652' => 0xF2, - '\u067E' => 0xF3, - '\u0679' => 0xF4, - '\u0686' => 0xF5, - '\u06D5' => 0xF6, - '\u06A4' => 0xF7, - '\u06AF' => 0xF8, - '\u0688' => 0xF9, - '\u0691' => 0xFA, - '\u0698' => 0xFE, - '\u06D2' => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Mac Arabic character + /// Mac Arabic character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\u0014' => 0x14, + '\uF8FF' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u00C4' => 0x80, + '\u00A0' => 0x81, + '\u00C7' => 0x82, + '\u00C9' => 0x83, + '\u00D1' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u00E1' => 0x87, + '\u00E0' => 0x88, + '\u00E2' => 0x89, + '\u00E4' => 0x8A, + '\u06BA' => 0x8B, + '\u00AB' => 0x8C, + '\u00E7' => 0x8D, + '\u00E9' => 0x8E, + '\u00E8' => 0x8F, + '\u00EA' => 0x90, + '\u00EB' => 0x91, + '\u00ED' => 0x92, + '\u2026' => 0x93, + '\u00EE' => 0x94, + '\u00EF' => 0x95, + '\u00F1' => 0x96, + '\u00F3' => 0x97, + '\u00BB' => 0x98, + '\u00F4' => 0x99, + '\u00F6' => 0x9A, + '\u00F7' => 0x9B, + '\u00FA' => 0x9C, + '\u00F9' => 0x9D, + '\u00FB' => 0x9E, + '\u00FC' => 0x9F, + '\u066A' => 0xA5, + '\u060C' => 0xAC, + '\u0660' => 0xB0, + '\u0661' => 0xB1, + '\u0662' => 0xB2, + '\u0663' => 0xB3, + '\u0664' => 0xB4, + '\u0665' => 0xB5, + '\u0666' => 0xB6, + '\u0667' => 0xB7, + '\u0668' => 0xB8, + '\u0669' => 0xB9, + '\u061B' => 0xBB, + '\u061F' => 0xBF, + '\u274A' => 0xC0, + '\u0621' => 0xC1, + '\u0622' => 0xC2, + '\u0623' => 0xC3, + '\u0624' => 0xC4, + '\u0625' => 0xC5, + '\u0626' => 0xC6, + '\u0627' => 0xC7, + '\u0628' => 0xC8, + '\u0629' => 0xC9, + '\u062A' => 0xCA, + '\u062B' => 0xCB, + '\u062C' => 0xCC, + '\u062D' => 0xCD, + '\u062E' => 0xCE, + '\u062F' => 0xCF, + '\u0630' => 0xD0, + '\u0631' => 0xD1, + '\u0632' => 0xD2, + '\u0633' => 0xD3, + '\u0634' => 0xD4, + '\u0635' => 0xD5, + '\u0636' => 0xD6, + '\u0637' => 0xD7, + '\u0638' => 0xD8, + '\u0639' => 0xD9, + '\u063A' => 0xDA, + '\u0640' => 0xE0, + '\u0641' => 0xE1, + '\u0642' => 0xE2, + '\u0643' => 0xE3, + '\u0644' => 0xE4, + '\u0645' => 0xE5, + '\u0646' => 0xE6, + '\u0647' => 0xE7, + '\u0648' => 0xE8, + '\u0649' => 0xE9, + '\u064A' => 0xEA, + '\u064B' => 0xEB, + '\u064C' => 0xEC, + '\u064D' => 0xED, + '\u064E' => 0xEE, + '\u064F' => 0xEF, + '\u0650' => 0xF0, + '\u0651' => 0xF1, + '\u0652' => 0xF2, + '\u067E' => 0xF3, + '\u0679' => 0xF4, + '\u0686' => 0xF5, + '\u06D5' => 0xF6, + '\u06A4' => 0xF7, + '\u06AF' => 0xF8, + '\u0688' => 0xF9, + '\u0691' => 0xFA, + '\u0698' => 0xFE, + '\u06D2' => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacCentralEuropean.cs b/Claunia.Encoding/MacCentralEuropean.cs index a38ebd0..dc62810 100644 --- a/Claunia.Encoding/MacCentralEuropean.cs +++ b/Claunia.Encoding/MacCentralEuropean.cs @@ -24,402 +24,401 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Mac CentralEuropean character encoding of Unicode characters. +public class MacCentralEuropean : SingleByteEncoding { - /// Represents an Mac CentralEuropean character encoding of Unicode characters. - public class MacCentralEuropean : SingleByteEncoding + /// + public override string BodyName => "x-mac-ce"; + /// + public override int CodePage => 10029; + /// + public override string EncodingName => "Central European (Mac)"; + /// + public override string HeaderName => "x-mac-ce"; + /// + public override string WebName => "x-mac-ce"; + /// + public override int WindowsCodePage => 10029; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Macintosh CentralEuropean to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "x-mac-ce"; - /// - public override int CodePage => 10029; - /// - public override string EncodingName => "Central European (Mac)"; - /// - public override string HeaderName => "x-mac-ce"; - /// - public override string WebName => "x-mac-ce"; - /// - public override int WindowsCodePage => 10029; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Macintosh CentralEuropean to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u00C4', '\u0100', '\u0101', '\u00C9', '\u0104', '\u00D6', '\u00DC', '\u00E1', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u0105', '\u010C', '\u00E4', '\u010D', '\u0106', '\u0107', '\u00E9', '\u0179', - // 0x80 - '\u00C4', '\u0100', '\u0101', '\u00C9', '\u0104', '\u00D6', '\u00DC', '\u00E1', + // 0x90 + '\u017A', '\u010E', '\u00ED', '\u010F', '\u0112', '\u0113', '\u0116', '\u00F3', - // 0x88 - '\u0105', '\u010C', '\u00E4', '\u010D', '\u0106', '\u0107', '\u00E9', '\u0179', + // 0x98 + '\u0117', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u011A', '\u011B', '\u00FC', - // 0x90 - '\u017A', '\u010E', '\u00ED', '\u010F', '\u0112', '\u0113', '\u0116', '\u00F3', + // 0xA0 + '\u2020', '\u00B0', '\u0118', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', - // 0x98 - '\u0117', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u011A', '\u011B', '\u00FC', + // 0xA8 + '\u00AE', '\u00A9', '\u2122', '\u0119', '\u00A8', '\u2260', '\u0123', '\u012E', - // 0xA0 - '\u2020', '\u00B0', '\u0118', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', + // 0xB0 + '\u012F', '\u012A', '\u2264', '\u2265', '\u012B', '\u0136', '\u2202', '\u2211', - // 0xA8 - '\u00AE', '\u00A9', '\u2122', '\u0119', '\u00A8', '\u2260', '\u0123', '\u012E', + // 0xB8 + '\u0142', '\u013B', '\u013C', '\u013D', '\u013E', '\u0139', '\u013A', '\u0145', - // 0xB0 - '\u012F', '\u012A', '\u2264', '\u2265', '\u012B', '\u0136', '\u2202', '\u2211', + // 0xC0 + '\u0146', '\u0143', '\u00AC', '\u221A', '\u0144', '\u0147', '\u2206', '\u00AB', - // 0xB8 - '\u0142', '\u013B', '\u013C', '\u013D', '\u013E', '\u0139', '\u013A', '\u0145', + // 0xC8 + '\u00BB', '\u2026', '\u00A0', '\u0148', '\u0150', '\u00D5', '\u0151', '\u014C', - // 0xC0 - '\u0146', '\u0143', '\u00AC', '\u221A', '\u0144', '\u0147', '\u2206', '\u00AB', + // 0xD0 + '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', - // 0xC8 - '\u00BB', '\u2026', '\u00A0', '\u0148', '\u0150', '\u00D5', '\u0151', '\u014C', + // 0xD8 + '\u014D', '\u0154', '\u0155', '\u0158', '\u2039', '\u203A', '\u0159', '\u0156', - // 0xD0 - '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', + // 0xE0 + '\u0157', '\u0160', '\u201A', '\u201E', '\u0161', '\u015A', '\u015B', '\u00C1', - // 0xD8 - '\u014D', '\u0154', '\u0155', '\u0158', '\u2039', '\u203A', '\u0159', '\u0156', + // 0xE8 + '\u0164', '\u0165', '\u00CD', '\u017D', '\u017E', '\u016A', '\u00D3', '\u00D4', - // 0xE0 - '\u0157', '\u0160', '\u201A', '\u201E', '\u0161', '\u015A', '\u015B', '\u00C1', + // 0xF0 + '\u016B', '\u016E', '\u00DA', '\u016F', '\u0170', '\u0171', '\u0172', '\u0173', - // 0xE8 - '\u0164', '\u0165', '\u00CD', '\u017D', '\u017E', '\u016A', '\u00D3', '\u00D4', + // 0xF8 + '\u00DD', '\u00FD', '\u0137', '\u017B', '\u0141', '\u017C', '\u0122', '\u02C7' + }; - // 0xF0 - '\u016B', '\u016E', '\u00DA', '\u016F', '\u0170', '\u0171', '\u0172', '\u0173', - - // 0xF8 - '\u00DD', '\u00FD', '\u0137', '\u017B', '\u0141', '\u017C', '\u0122', '\u02C7' - }; - - /// Converts a Unicode character to an Mac CentralEuropean character - /// Mac CentralEuropean character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\u0014' => 0x14, - '\uF8FF' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u00C4' => 0x80, - '\u0100' => 0x81, - '\u0101' => 0x82, - '\u00C9' => 0x83, - '\u0104' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u00E1' => 0x87, - '\u0105' => 0x88, - '\u010C' => 0x89, - '\u00E4' => 0x8A, - '\u010D' => 0x8B, - '\u0106' => 0x8C, - '\u0107' => 0x8D, - '\u00E9' => 0x8E, - '\u0179' => 0x8F, - '\u017A' => 0x90, - '\u010E' => 0x91, - '\u00ED' => 0x92, - '\u010F' => 0x93, - '\u0112' => 0x94, - '\u0113' => 0x95, - '\u0116' => 0x96, - '\u00F3' => 0x97, - '\u0117' => 0x98, - '\u00F4' => 0x99, - '\u00F6' => 0x9A, - '\u00F5' => 0x9B, - '\u00FA' => 0x9C, - '\u011A' => 0x9D, - '\u011B' => 0x9E, - '\u00FC' => 0x9F, - '\u2020' => 0xA0, - '\u00B0' => 0xA1, - '\u0118' => 0xA2, - '\u00A3' => 0xA3, - '\u00A7' => 0xA4, - '\u2022' => 0xA5, - '\u00B6' => 0xA6, - '\u00DF' => 0xA7, - '\u00AE' => 0xA8, - '\u00A9' => 0xA9, - '\u2122' => 0xAA, - '\u0119' => 0xAB, - '\u00A8' => 0xAC, - '\u2260' => 0xAD, - '\u0123' => 0xAE, - '\u012E' => 0xAF, - '\u012F' => 0xB0, - '\u012A' => 0xB1, - '\u2264' => 0xB2, - '\u2265' => 0xB3, - '\u012B' => 0xB4, - '\u0136' => 0xB5, - '\u2202' => 0xB6, - '\u2211' => 0xB7, - '\u0142' => 0xB8, - '\u013B' => 0xB9, - '\u013C' => 0xBA, - '\u013D' => 0xBB, - '\u013E' => 0xBC, - '\u0139' => 0xBD, - '\u013A' => 0xBE, - '\u0145' => 0xBF, - '\u0146' => 0xC0, - '\u0143' => 0xC1, - '\u00AC' => 0xC2, - '\u221A' => 0xC3, - '\u0144' => 0xC4, - '\u0147' => 0xC5, - '\u2206' => 0xC6, - '\u00AB' => 0xC7, - '\u00BB' => 0xC8, - '\u2026' => 0xC9, - '\u00A0' => 0xCA, - '\u0148' => 0xCB, - '\u0150' => 0xCC, - '\u00D5' => 0xCD, - '\u0151' => 0xCE, - '\u014C' => 0xCF, - '\u2013' => 0xD0, - '\u2014' => 0xD1, - '\u201C' => 0xD2, - '\u201D' => 0xD3, - '\u2018' => 0xD4, - '\u2019' => 0xD5, - '\u00F7' => 0xD6, - '\u05CA' => 0xD7, - '\u014D' => 0xD8, - '\u0154' => 0xD9, - '\u0155' => 0xDA, - '\u0158' => 0xDB, - '\u2039' => 0xDC, - '\u203A' => 0xDD, - '\u0159' => 0xDE, - '\u0156' => 0xDF, - '\u0157' => 0xE0, - '\u0160' => 0xE1, - '\u201A' => 0xE2, - '\u201E' => 0xE3, - '\u0161' => 0xE4, - '\u015A' => 0xE5, - '\u015B' => 0xE6, - '\u00C1' => 0xE7, - '\u0164' => 0xE8, - '\u0165' => 0xE9, - '\u00CD' => 0xEA, - '\u017D' => 0xEB, - '\u017E' => 0xEC, - '\u016A' => 0xED, - '\u00D3' => 0xEE, - '\u00D4' => 0xEF, - '\u016B' => 0xF0, - '\u016E' => 0xF1, - '\u00DA' => 0xF2, - '\u016F' => 0xF3, - '\u0170' => 0xF4, - '\u0171' => 0xF5, - '\u0172' => 0xF6, - '\u0173' => 0xF7, - '\u00DD' => 0xF8, - '\u00FD' => 0xF9, - '\u0137' => 0xFA, - '\u017B' => 0xFB, - '\u0141' => 0xFC, - '\u017C' => 0xFD, - '\u0122' => 0xFE, - '\u02C7' => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Mac CentralEuropean character + /// Mac CentralEuropean character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\u0014' => 0x14, + '\uF8FF' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u00C4' => 0x80, + '\u0100' => 0x81, + '\u0101' => 0x82, + '\u00C9' => 0x83, + '\u0104' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u00E1' => 0x87, + '\u0105' => 0x88, + '\u010C' => 0x89, + '\u00E4' => 0x8A, + '\u010D' => 0x8B, + '\u0106' => 0x8C, + '\u0107' => 0x8D, + '\u00E9' => 0x8E, + '\u0179' => 0x8F, + '\u017A' => 0x90, + '\u010E' => 0x91, + '\u00ED' => 0x92, + '\u010F' => 0x93, + '\u0112' => 0x94, + '\u0113' => 0x95, + '\u0116' => 0x96, + '\u00F3' => 0x97, + '\u0117' => 0x98, + '\u00F4' => 0x99, + '\u00F6' => 0x9A, + '\u00F5' => 0x9B, + '\u00FA' => 0x9C, + '\u011A' => 0x9D, + '\u011B' => 0x9E, + '\u00FC' => 0x9F, + '\u2020' => 0xA0, + '\u00B0' => 0xA1, + '\u0118' => 0xA2, + '\u00A3' => 0xA3, + '\u00A7' => 0xA4, + '\u2022' => 0xA5, + '\u00B6' => 0xA6, + '\u00DF' => 0xA7, + '\u00AE' => 0xA8, + '\u00A9' => 0xA9, + '\u2122' => 0xAA, + '\u0119' => 0xAB, + '\u00A8' => 0xAC, + '\u2260' => 0xAD, + '\u0123' => 0xAE, + '\u012E' => 0xAF, + '\u012F' => 0xB0, + '\u012A' => 0xB1, + '\u2264' => 0xB2, + '\u2265' => 0xB3, + '\u012B' => 0xB4, + '\u0136' => 0xB5, + '\u2202' => 0xB6, + '\u2211' => 0xB7, + '\u0142' => 0xB8, + '\u013B' => 0xB9, + '\u013C' => 0xBA, + '\u013D' => 0xBB, + '\u013E' => 0xBC, + '\u0139' => 0xBD, + '\u013A' => 0xBE, + '\u0145' => 0xBF, + '\u0146' => 0xC0, + '\u0143' => 0xC1, + '\u00AC' => 0xC2, + '\u221A' => 0xC3, + '\u0144' => 0xC4, + '\u0147' => 0xC5, + '\u2206' => 0xC6, + '\u00AB' => 0xC7, + '\u00BB' => 0xC8, + '\u2026' => 0xC9, + '\u00A0' => 0xCA, + '\u0148' => 0xCB, + '\u0150' => 0xCC, + '\u00D5' => 0xCD, + '\u0151' => 0xCE, + '\u014C' => 0xCF, + '\u2013' => 0xD0, + '\u2014' => 0xD1, + '\u201C' => 0xD2, + '\u201D' => 0xD3, + '\u2018' => 0xD4, + '\u2019' => 0xD5, + '\u00F7' => 0xD6, + '\u05CA' => 0xD7, + '\u014D' => 0xD8, + '\u0154' => 0xD9, + '\u0155' => 0xDA, + '\u0158' => 0xDB, + '\u2039' => 0xDC, + '\u203A' => 0xDD, + '\u0159' => 0xDE, + '\u0156' => 0xDF, + '\u0157' => 0xE0, + '\u0160' => 0xE1, + '\u201A' => 0xE2, + '\u201E' => 0xE3, + '\u0161' => 0xE4, + '\u015A' => 0xE5, + '\u015B' => 0xE6, + '\u00C1' => 0xE7, + '\u0164' => 0xE8, + '\u0165' => 0xE9, + '\u00CD' => 0xEA, + '\u017D' => 0xEB, + '\u017E' => 0xEC, + '\u016A' => 0xED, + '\u00D3' => 0xEE, + '\u00D4' => 0xEF, + '\u016B' => 0xF0, + '\u016E' => 0xF1, + '\u00DA' => 0xF2, + '\u016F' => 0xF3, + '\u0170' => 0xF4, + '\u0171' => 0xF5, + '\u0172' => 0xF6, + '\u0173' => 0xF7, + '\u00DD' => 0xF8, + '\u00FD' => 0xF9, + '\u0137' => 0xFA, + '\u017B' => 0xFB, + '\u0141' => 0xFC, + '\u017C' => 0xFD, + '\u0122' => 0xFE, + '\u02C7' => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacCroatian.cs b/Claunia.Encoding/MacCroatian.cs index 85aba82..9372c28 100644 --- a/Claunia.Encoding/MacCroatian.cs +++ b/Claunia.Encoding/MacCroatian.cs @@ -24,401 +24,400 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Mac Croatian character encoding of Unicode characters. +public class MacCroatian : SingleByteEncoding { - /// Represents an Mac Croatian character encoding of Unicode characters. - public class MacCroatian : SingleByteEncoding + /// + public override string BodyName => "x-mac-croatian"; + /// + public override int CodePage => 10082; + /// + public override string EncodingName => "Croatian (Mac)"; + /// + public override string HeaderName => "x-mac-croatian"; + /// + public override string WebName => "x-mac-croatian"; + /// + public override int WindowsCodePage => 10082; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Macintosh Croatian to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "x-mac-croatian"; - /// - public override int CodePage => 10082; - /// - public override string EncodingName => "Croatian (Mac)"; - /// - public override string HeaderName => "x-mac-croatian"; - /// - public override string WebName => "x-mac-croatian"; - /// - public override int WindowsCodePage => 10082; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Macintosh Croatian to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', - // 0x80 - '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', + // 0x90 + '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', - // 0x88 - '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', + // 0x98 + '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', - // 0x90 - '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', + // 0xA0 + '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', - // 0x98 - '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', + // 0xA8 + '\u00AE', '\u0160', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u017D', '\u00D8', - // 0xA0 - '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', + // 0xB0 + '\u221E', '\u00B1', '\u2264', '\u2265', '\u2206', '\u00B5', '\u2202', '\u2211', - // 0xA8 - '\u00AE', '\u0160', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u017D', '\u00D8', + // 0xB8 + '\u220F', '\u0161', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u017E', '\u00F8', - // 0xB0 - '\u221E', '\u00B1', '\u2264', '\u2265', '\u2206', '\u00B5', '\u2202', '\u2211', + // 0xC0 + '\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u0106', '\u00AB', - // 0xB8 - '\u220F', '\u0161', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u017E', '\u00F8', + // 0xC8 + '\u010C', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', - // 0xC0 - '\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u0106', '\u00AB', + // 0xD0 + '\u0110', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', - // 0xC8 - '\u010C', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', + // 0xD8 + '\uF8FF', '\u00A9', '\u2044', '\u20AC', '\u2039', '\u203A', '\u00C6', '\u00BB', - // 0xD0 - '\u0110', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', + // 0xE0 + '\u2013', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u0107', '\u00C1', - // 0xD8 - '\uF8FF', '\u00A9', '\u2044', '\u20AC', '\u2039', '\u203A', '\u00C6', '\u00BB', + // 0xE8 + '\u010D', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', - // 0xE0 - '\u2013', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u0107', '\u00C1', + // 0xF0 + '\u0111', '\u00D2', '\u00DA', '\u00D8', '\u00D9', '\u0131', '\u02C6', '\u02DC', - // 0xE8 - '\u010D', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', + // 0xF8 + '\u00AF', '\u03C0', '\u00CB', '\u02DA', '\u00B8', '\u00CA', '\u00E6', '\u02C7' + }; - // 0xF0 - '\u0111', '\u00D2', '\u00DA', '\u00D8', '\u00D9', '\u0131', '\u02C6', '\u02DC', - - // 0xF8 - '\u00AF', '\u03C0', '\u00CB', '\u02DA', '\u00B8', '\u00CA', '\u00E6', '\u02C7' - }; - - /// Converts a Unicode character to an Mac Croatian character - /// Mac Croatian character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\u0014' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u00C4' => 0x80, - '\u00C5' => 0x81, - '\u00C7' => 0x82, - '\u00C9' => 0x83, - '\u00D1' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u00E1' => 0x87, - '\u00E0' => 0x88, - '\u00E2' => 0x89, - '\u00E4' => 0x8A, - '\u00E3' => 0x8B, - '\u00E5' => 0x8C, - '\u00E7' => 0x8D, - '\u00E9' => 0x8E, - '\u00E8' => 0x8F, - '\u00EA' => 0x90, - '\u00EB' => 0x91, - '\u00ED' => 0x92, - '\u00EC' => 0x93, - '\u00EE' => 0x94, - '\u00EF' => 0x95, - '\u00F1' => 0x96, - '\u00F3' => 0x97, - '\u00F2' => 0x98, - '\u00F4' => 0x99, - '\u00F6' => 0x9A, - '\u00F5' => 0x9B, - '\u00FA' => 0x9C, - '\u00F9' => 0x9D, - '\u00FB' => 0x9E, - '\u00FC' => 0x9F, - '\u2020' => 0xA0, - '\u00B0' => 0xA1, - '\u00A2' => 0xA2, - '\u00A3' => 0xA3, - '\u00A7' => 0xA4, - '\u2022' => 0xA5, - '\u00B6' => 0xA6, - '\u00DF' => 0xA7, - '\u00AE' => 0xA8, - '\u0160' => 0xA9, - '\u2122' => 0xAA, - '\u00B4' => 0xAB, - '\u00A8' => 0xAC, - '\u2260' => 0xAD, - '\u017D' => 0xAE, - '\u00D8' => 0xAF, - '\u221E' => 0xB0, - '\u00B1' => 0xB1, - '\u2264' => 0xB2, - '\u2265' => 0xB3, - '\u2206' => 0xB4, - '\u00B5' => 0xB5, - '\u2202' => 0xB6, - '\u2211' => 0xB7, - '\u220F' => 0xB8, - '\u0161' => 0xB9, - '\u222B' => 0xBA, - '\u00AA' => 0xBB, - '\u00BA' => 0xBC, - '\u03A9' => 0xBD, - '\u017E' => 0xBE, - '\u00F8' => 0xBF, - '\u00BF' => 0xC0, - '\u00A1' => 0xC1, - '\u00AC' => 0xC2, - '\u221A' => 0xC3, - '\u0192' => 0xC4, - '\u2248' => 0xC5, - '\u0106' => 0xC6, - '\u00AB' => 0xC7, - '\u010C' => 0xC8, - '\u2026' => 0xC9, - '\u00A0' => 0xCA, - '\u00C0' => 0xCB, - '\u00C3' => 0xCC, - '\u00D5' => 0xCD, - '\u0152' => 0xCE, - '\u0153' => 0xCF, - '\u0110' => 0xD0, - '\u2014' => 0xD1, - '\u201C' => 0xD2, - '\u201D' => 0xD3, - '\u2018' => 0xD4, - '\u2019' => 0xD5, - '\u00F7' => 0xD6, - '\u25CA' => 0xD7, - '\uF8FF' => 0xD8, - '\u00A9' => 0xD9, - '\u2044' => 0xDA, - '\u20AC' => 0xDB, - '\u2039' => 0xDC, - '\u203A' => 0xDD, - '\u00C6' => 0xDE, - '\u00BB' => 0xDF, - '\u2013' => 0xE0, - '\u00B7' => 0xE1, - '\u201A' => 0xE2, - '\u201E' => 0xE3, - '\u2030' => 0xE4, - '\u00C2' => 0xE5, - '\u0107' => 0xE6, - '\u00C1' => 0xE7, - '\u010D' => 0xE8, - '\u00C8' => 0xE9, - '\u00CD' => 0xEA, - '\u00CE' => 0xEB, - '\u00CF' => 0xEC, - '\u00CC' => 0xED, - '\u00D3' => 0xEE, - '\u00D4' => 0xEF, - '\u0111' => 0xF0, - '\u00D2' => 0xF1, - '\u00DA' => 0xF2, - '\u00DB' => 0xF3, - '\u00D9' => 0xF4, - '\u0131' => 0xF5, - '\u02C6' => 0xF6, - '\u02DC' => 0xF7, - '\u00AF' => 0xF8, - '\u03C0' => 0xF9, - '\u00CB' => 0xFA, - '\u02DA' => 0xFB, - '\u00B8' => 0xFC, - '\u00CA' => 0xFD, - '\u00E6' => 0xFE, - '\u02C7' => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Mac Croatian character + /// Mac Croatian character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\u0014' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u00C4' => 0x80, + '\u00C5' => 0x81, + '\u00C7' => 0x82, + '\u00C9' => 0x83, + '\u00D1' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u00E1' => 0x87, + '\u00E0' => 0x88, + '\u00E2' => 0x89, + '\u00E4' => 0x8A, + '\u00E3' => 0x8B, + '\u00E5' => 0x8C, + '\u00E7' => 0x8D, + '\u00E9' => 0x8E, + '\u00E8' => 0x8F, + '\u00EA' => 0x90, + '\u00EB' => 0x91, + '\u00ED' => 0x92, + '\u00EC' => 0x93, + '\u00EE' => 0x94, + '\u00EF' => 0x95, + '\u00F1' => 0x96, + '\u00F3' => 0x97, + '\u00F2' => 0x98, + '\u00F4' => 0x99, + '\u00F6' => 0x9A, + '\u00F5' => 0x9B, + '\u00FA' => 0x9C, + '\u00F9' => 0x9D, + '\u00FB' => 0x9E, + '\u00FC' => 0x9F, + '\u2020' => 0xA0, + '\u00B0' => 0xA1, + '\u00A2' => 0xA2, + '\u00A3' => 0xA3, + '\u00A7' => 0xA4, + '\u2022' => 0xA5, + '\u00B6' => 0xA6, + '\u00DF' => 0xA7, + '\u00AE' => 0xA8, + '\u0160' => 0xA9, + '\u2122' => 0xAA, + '\u00B4' => 0xAB, + '\u00A8' => 0xAC, + '\u2260' => 0xAD, + '\u017D' => 0xAE, + '\u00D8' => 0xAF, + '\u221E' => 0xB0, + '\u00B1' => 0xB1, + '\u2264' => 0xB2, + '\u2265' => 0xB3, + '\u2206' => 0xB4, + '\u00B5' => 0xB5, + '\u2202' => 0xB6, + '\u2211' => 0xB7, + '\u220F' => 0xB8, + '\u0161' => 0xB9, + '\u222B' => 0xBA, + '\u00AA' => 0xBB, + '\u00BA' => 0xBC, + '\u03A9' => 0xBD, + '\u017E' => 0xBE, + '\u00F8' => 0xBF, + '\u00BF' => 0xC0, + '\u00A1' => 0xC1, + '\u00AC' => 0xC2, + '\u221A' => 0xC3, + '\u0192' => 0xC4, + '\u2248' => 0xC5, + '\u0106' => 0xC6, + '\u00AB' => 0xC7, + '\u010C' => 0xC8, + '\u2026' => 0xC9, + '\u00A0' => 0xCA, + '\u00C0' => 0xCB, + '\u00C3' => 0xCC, + '\u00D5' => 0xCD, + '\u0152' => 0xCE, + '\u0153' => 0xCF, + '\u0110' => 0xD0, + '\u2014' => 0xD1, + '\u201C' => 0xD2, + '\u201D' => 0xD3, + '\u2018' => 0xD4, + '\u2019' => 0xD5, + '\u00F7' => 0xD6, + '\u25CA' => 0xD7, + '\uF8FF' => 0xD8, + '\u00A9' => 0xD9, + '\u2044' => 0xDA, + '\u20AC' => 0xDB, + '\u2039' => 0xDC, + '\u203A' => 0xDD, + '\u00C6' => 0xDE, + '\u00BB' => 0xDF, + '\u2013' => 0xE0, + '\u00B7' => 0xE1, + '\u201A' => 0xE2, + '\u201E' => 0xE3, + '\u2030' => 0xE4, + '\u00C2' => 0xE5, + '\u0107' => 0xE6, + '\u00C1' => 0xE7, + '\u010D' => 0xE8, + '\u00C8' => 0xE9, + '\u00CD' => 0xEA, + '\u00CE' => 0xEB, + '\u00CF' => 0xEC, + '\u00CC' => 0xED, + '\u00D3' => 0xEE, + '\u00D4' => 0xEF, + '\u0111' => 0xF0, + '\u00D2' => 0xF1, + '\u00DA' => 0xF2, + '\u00DB' => 0xF3, + '\u00D9' => 0xF4, + '\u0131' => 0xF5, + '\u02C6' => 0xF6, + '\u02DC' => 0xF7, + '\u00AF' => 0xF8, + '\u03C0' => 0xF9, + '\u00CB' => 0xFA, + '\u02DA' => 0xFB, + '\u00B8' => 0xFC, + '\u00CA' => 0xFD, + '\u00E6' => 0xFE, + '\u02C7' => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacCyrillic.cs b/Claunia.Encoding/MacCyrillic.cs index 1c6ee62..a239de4 100644 --- a/Claunia.Encoding/MacCyrillic.cs +++ b/Claunia.Encoding/MacCyrillic.cs @@ -24,402 +24,401 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Mac Cyrillic character encoding of Unicode characters. +public class MacCyrillic : SingleByteEncoding { - /// Represents an Mac Cyrillic character encoding of Unicode characters. - public class MacCyrillic : SingleByteEncoding + /// + public override string BodyName => "x-mac-cyrillic"; + /// + public override int CodePage => 10007; + /// + public override string EncodingName => "Cyrillic (Mac)"; + /// + public override string HeaderName => "x-mac-cyrillic"; + /// + public override string WebName => "x-mac-cyrillic"; + /// + public override int WindowsCodePage => 10007; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Macintosh Cyrillic to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "x-mac-cyrillic"; - /// - public override int CodePage => 10007; - /// - public override string EncodingName => "Cyrillic (Mac)"; - /// - public override string HeaderName => "x-mac-cyrillic"; - /// - public override string WebName => "x-mac-cyrillic"; - /// - public override int WindowsCodePage => 10007; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Macintosh Cyrillic to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416', '\u0417', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D', '\u041E', '\u041F', - // 0x80 - '\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416', '\u0417', + // 0x90 + '\u0420', '\u0421', '\u0422', '\u0423', '\u0424', '\u0425', '\u0426', '\u0427', - // 0x88 - '\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D', '\u041E', '\u041F', + // 0x98 + '\u0428', '\u0429', '\u042A', '\u042B', '\u042C', '\u042D', '\u042E', '\u042F', - // 0x90 - '\u0420', '\u0421', '\u0422', '\u0423', '\u0424', '\u0425', '\u0426', '\u0427', + // 0xA0 + '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u0406', - // 0x98 - '\u0428', '\u0429', '\u042A', '\u042B', '\u042C', '\u042D', '\u042E', '\u042F', + // 0xA8 + '\u00AE', '\u00A9', '\u2122', '\u0402', '\u0452', '\u2260', '\u0403', '\u0453', - // 0xA0 - '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u0406', + // 0xB0 + '\u221E', '\u00B1', '\u2264', '\u2265', '\u0456', '\u00B5', '\u2202', '\u0408', - // 0xA8 - '\u00AE', '\u00A9', '\u2122', '\u0402', '\u0452', '\u2260', '\u0403', '\u0453', + // 0xB8 + '\u0404', '\u0454', '\u0407', '\u0457', '\u0409', '\u0459', '\u040A', '\u045A', - // 0xB0 - '\u221E', '\u00B1', '\u2264', '\u2265', '\u0456', '\u00B5', '\u2202', '\u0408', + // 0xC0 + '\u0458', '\u0405', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', - // 0xB8 - '\u0404', '\u0454', '\u0407', '\u0457', '\u0409', '\u0459', '\u040A', '\u045A', + // 0xC8 + '\u00BB', '\u2026', '\u00A0', '\u040B', '\u045B', '\u040C', '\u045C', '\u0455', - // 0xC0 - '\u0458', '\u0405', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', + // 0xD0 + '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u201E', - // 0xC8 - '\u00BB', '\u2026', '\u00A0', '\u040B', '\u045B', '\u040C', '\u045C', '\u0455', + // 0xD8 + '\u040E', '\u045E', '\u040F', '\u045F', '\u2116', '\u0401', '\u0451', '\u044F', - // 0xD0 - '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u201E', + // 0xE0 + '\u0430', '\u0431', '\u0432', '\u0433', '\u0434', '\u0435', '\u0436', '\u0437', - // 0xD8 - '\u040E', '\u045E', '\u040F', '\u045F', '\u2116', '\u0401', '\u0451', '\u044F', + // 0xE8 + '\u0438', '\u0439', '\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F', - // 0xE0 - '\u0430', '\u0431', '\u0432', '\u0433', '\u0434', '\u0435', '\u0436', '\u0437', + // 0xF0 + '\u0440', '\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447', - // 0xE8 - '\u0438', '\u0439', '\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F', + // 0xF8 + '\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E', '\u20AC' + }; - // 0xF0 - '\u0440', '\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447', - - // 0xF8 - '\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E', '\u20AC' - }; - - /// Converts a Unicode character to an Mac Cyrillic character - /// Mac Cyrillic character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\u0014' => 0x14, - '\uF8FF' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u0410' => 0x80, - '\u0411' => 0x81, - '\u0412' => 0x82, - '\u0413' => 0x83, - '\u0414' => 0x84, - '\u0415' => 0x85, - '\u0416' => 0x86, - '\u0417' => 0x87, - '\u0418' => 0x88, - '\u0419' => 0x89, - '\u041A' => 0x8A, - '\u041B' => 0x8B, - '\u041C' => 0x8C, - '\u041D' => 0x8D, - '\u041E' => 0x8E, - '\u041F' => 0x8F, - '\u0420' => 0x90, - '\u0421' => 0x91, - '\u0422' => 0x92, - '\u0423' => 0x93, - '\u0424' => 0x94, - '\u0425' => 0x95, - '\u0426' => 0x96, - '\u0427' => 0x97, - '\u0428' => 0x98, - '\u0429' => 0x99, - '\u042A' => 0x9A, - '\u042B' => 0x9B, - '\u042C' => 0x9C, - '\u042D' => 0x9D, - '\u042E' => 0x9E, - '\u042F' => 0x9F, - '\u2020' => 0xA0, - '\u00B0' => 0xA1, - '\u0490' => 0xA2, - '\u00A3' => 0xA3, - '\u00A7' => 0xA4, - '\u2022' => 0xA5, - '\u00B6' => 0xA6, - '\u0406' => 0xA7, - '\u00AE' => 0xA8, - '\u00A9' => 0xA9, - '\u2122' => 0xAA, - '\u0402' => 0xAB, - '\u0452' => 0xAC, - '\u2260' => 0xAD, - '\u0403' => 0xAE, - '\u0453' => 0xAF, - '\u221E' => 0xB0, - '\u00B1' => 0xB1, - '\u2264' => 0xB2, - '\u2265' => 0xB3, - '\u0456' => 0xB4, - '\u00B5' => 0xB5, - '\u0491' => 0xB6, - '\u0408' => 0xB7, - '\u0404' => 0xB8, - '\u0454' => 0xB9, - '\u0407' => 0xBA, - '\u0457' => 0xBB, - '\u0409' => 0xBC, - '\u0459' => 0xBD, - '\u040A' => 0xBE, - '\u045A' => 0xBF, - '\u0458' => 0xC0, - '\u0405' => 0xC1, - '\u00AC' => 0xC2, - '\u221A' => 0xC3, - '\u0192' => 0xC4, - '\u2248' => 0xC5, - '\u2206' => 0xC6, - '\u00AB' => 0xC7, - '\u00BB' => 0xC8, - '\u2026' => 0xC9, - '\u00A0' => 0xCA, - '\u040B' => 0xCB, - '\u045B' => 0xCC, - '\u040C' => 0xCD, - '\u045C' => 0xCE, - '\u0455' => 0xCF, - '\u2013' => 0xD0, - '\u2014' => 0xD1, - '\u201C' => 0xD2, - '\u201D' => 0xD3, - '\u2018' => 0xD4, - '\u2019' => 0xD5, - '\u00F7' => 0xD6, - '\u201E' => 0xD7, - '\u040E' => 0xD8, - '\u045E' => 0xD9, - '\u040F' => 0xDA, - '\u045F' => 0xDB, - '\u2116' => 0xDC, - '\u0401' => 0xDD, - '\u0451' => 0xDE, - '\u044F' => 0xDF, - '\u0430' => 0xE0, - '\u0431' => 0xE1, - '\u0432' => 0xE2, - '\u0433' => 0xE3, - '\u0434' => 0xE4, - '\u0435' => 0xE5, - '\u0436' => 0xE6, - '\u0437' => 0xE7, - '\u0438' => 0xE8, - '\u0439' => 0xE9, - '\u043A' => 0xEA, - '\u043B' => 0xEB, - '\u043C' => 0xEC, - '\u043D' => 0xED, - '\u043E' => 0xEE, - '\u043F' => 0xEF, - '\u0440' => 0xF0, - '\u0441' => 0xF1, - '\u0442' => 0xF2, - '\u0443' => 0xF3, - '\u0444' => 0xF4, - '\u0445' => 0xF5, - '\u0446' => 0xF6, - '\u0447' => 0xF7, - '\u0448' => 0xF8, - '\u0449' => 0xF9, - '\u044A' => 0xFA, - '\u044B' => 0xFB, - '\u044C' => 0xFC, - '\u044D' => 0xFD, - '\u044E' => 0xFE, - '\u20AC' => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Mac Cyrillic character + /// Mac Cyrillic character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\u0014' => 0x14, + '\uF8FF' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u0410' => 0x80, + '\u0411' => 0x81, + '\u0412' => 0x82, + '\u0413' => 0x83, + '\u0414' => 0x84, + '\u0415' => 0x85, + '\u0416' => 0x86, + '\u0417' => 0x87, + '\u0418' => 0x88, + '\u0419' => 0x89, + '\u041A' => 0x8A, + '\u041B' => 0x8B, + '\u041C' => 0x8C, + '\u041D' => 0x8D, + '\u041E' => 0x8E, + '\u041F' => 0x8F, + '\u0420' => 0x90, + '\u0421' => 0x91, + '\u0422' => 0x92, + '\u0423' => 0x93, + '\u0424' => 0x94, + '\u0425' => 0x95, + '\u0426' => 0x96, + '\u0427' => 0x97, + '\u0428' => 0x98, + '\u0429' => 0x99, + '\u042A' => 0x9A, + '\u042B' => 0x9B, + '\u042C' => 0x9C, + '\u042D' => 0x9D, + '\u042E' => 0x9E, + '\u042F' => 0x9F, + '\u2020' => 0xA0, + '\u00B0' => 0xA1, + '\u0490' => 0xA2, + '\u00A3' => 0xA3, + '\u00A7' => 0xA4, + '\u2022' => 0xA5, + '\u00B6' => 0xA6, + '\u0406' => 0xA7, + '\u00AE' => 0xA8, + '\u00A9' => 0xA9, + '\u2122' => 0xAA, + '\u0402' => 0xAB, + '\u0452' => 0xAC, + '\u2260' => 0xAD, + '\u0403' => 0xAE, + '\u0453' => 0xAF, + '\u221E' => 0xB0, + '\u00B1' => 0xB1, + '\u2264' => 0xB2, + '\u2265' => 0xB3, + '\u0456' => 0xB4, + '\u00B5' => 0xB5, + '\u0491' => 0xB6, + '\u0408' => 0xB7, + '\u0404' => 0xB8, + '\u0454' => 0xB9, + '\u0407' => 0xBA, + '\u0457' => 0xBB, + '\u0409' => 0xBC, + '\u0459' => 0xBD, + '\u040A' => 0xBE, + '\u045A' => 0xBF, + '\u0458' => 0xC0, + '\u0405' => 0xC1, + '\u00AC' => 0xC2, + '\u221A' => 0xC3, + '\u0192' => 0xC4, + '\u2248' => 0xC5, + '\u2206' => 0xC6, + '\u00AB' => 0xC7, + '\u00BB' => 0xC8, + '\u2026' => 0xC9, + '\u00A0' => 0xCA, + '\u040B' => 0xCB, + '\u045B' => 0xCC, + '\u040C' => 0xCD, + '\u045C' => 0xCE, + '\u0455' => 0xCF, + '\u2013' => 0xD0, + '\u2014' => 0xD1, + '\u201C' => 0xD2, + '\u201D' => 0xD3, + '\u2018' => 0xD4, + '\u2019' => 0xD5, + '\u00F7' => 0xD6, + '\u201E' => 0xD7, + '\u040E' => 0xD8, + '\u045E' => 0xD9, + '\u040F' => 0xDA, + '\u045F' => 0xDB, + '\u2116' => 0xDC, + '\u0401' => 0xDD, + '\u0451' => 0xDE, + '\u044F' => 0xDF, + '\u0430' => 0xE0, + '\u0431' => 0xE1, + '\u0432' => 0xE2, + '\u0433' => 0xE3, + '\u0434' => 0xE4, + '\u0435' => 0xE5, + '\u0436' => 0xE6, + '\u0437' => 0xE7, + '\u0438' => 0xE8, + '\u0439' => 0xE9, + '\u043A' => 0xEA, + '\u043B' => 0xEB, + '\u043C' => 0xEC, + '\u043D' => 0xED, + '\u043E' => 0xEE, + '\u043F' => 0xEF, + '\u0440' => 0xF0, + '\u0441' => 0xF1, + '\u0442' => 0xF2, + '\u0443' => 0xF3, + '\u0444' => 0xF4, + '\u0445' => 0xF5, + '\u0446' => 0xF6, + '\u0447' => 0xF7, + '\u0448' => 0xF8, + '\u0449' => 0xF9, + '\u044A' => 0xFA, + '\u044B' => 0xFB, + '\u044C' => 0xFC, + '\u044D' => 0xFD, + '\u044E' => 0xFE, + '\u20AC' => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacFarsi.cs b/Claunia.Encoding/MacFarsi.cs index 1f0caaa..369461f 100644 --- a/Claunia.Encoding/MacFarsi.cs +++ b/Claunia.Encoding/MacFarsi.cs @@ -24,376 +24,375 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Mac Farsi character encoding of Unicode characters. +public class MacFarsi : SingleByteEncoding { - /// Represents an Mac Farsi character encoding of Unicode characters. - public class MacFarsi : SingleByteEncoding + /// + public override string BodyName => "x-mac-farsi"; + /// + public override int CodePage => 10014; + /// + public override string EncodingName => "Farsi (Mac)"; + /// + public override string HeaderName => "x-mac-farsi"; + /// + public override string WebName => "x-mac-farsi"; + /// + public override int WindowsCodePage => 10014; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Macintosh Farsi to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "x-mac-farsi"; - /// - public override int CodePage => 10014; - /// - public override string EncodingName => "Farsi (Mac)"; - /// - public override string HeaderName => "x-mac-farsi"; - /// - public override string WebName => "x-mac-farsi"; - /// - public override int WindowsCodePage => 10014; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Macintosh Farsi to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u00C4', '\u00A0', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u00E0', '\u00E2', '\u00E4', '\u06BA', '\u00AB', '\u00E7', '\u00E9', '\u00E8', - // 0x80 - '\u00C4', '\u00A0', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', + // 0x90 + '\u00EA', '\u00EB', '\u00ED', '\u2026', '\u00EE', '\u00EF', '\u00F1', '\u00F3', - // 0x88 - '\u00E0', '\u00E2', '\u00E4', '\u06BA', '\u00AB', '\u00E7', '\u00E9', '\u00E8', + // 0x98 + '\u00BB', '\u00F4', '\u00F6', '\u00F7', '\u00FA', '\u00F9', '\u00FB', '\u00FC', - // 0x90 - '\u00EA', '\u00EB', '\u00ED', '\u2026', '\u00EE', '\u00EF', '\u00F1', '\u00F3', + // 0xA0 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u066A', '\u0026', '\u0027', - // 0x98 - '\u00BB', '\u00F4', '\u00F6', '\u00F7', '\u00FA', '\u00F9', '\u00FB', '\u00FC', + // 0xA8 + '\u0028', '\u0029', '\u002A', '\u002B', '\u060C', '\u002D', '\u002E', '\u002F', - // 0xA0 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u066A', '\u0026', '\u0027', + // 0xB0 + '\u06F0', '\u06F1', '\u06F2', '\u06F3', '\u06F4', '\u06F5', '\u06F6', '\u06F7', - // 0xA8 - '\u0028', '\u0029', '\u002A', '\u002B', '\u060C', '\u002D', '\u002E', '\u002F', + // 0xB8 + '\u06F8', '\u06F9', '\u003A', '\u061B', '\u003C', '\u003D', '\u003E', '\u061F', - // 0xB0 - '\u06F0', '\u06F1', '\u06F2', '\u06F3', '\u06F4', '\u06F5', '\u06F6', '\u06F7', + // 0xC0 + '\u274A', '\u0621', '\u0622', '\u0623', '\u0624', '\u0625', '\u0626', '\u0627', - // 0xB8 - '\u06F8', '\u06F9', '\u003A', '\u061B', '\u003C', '\u003D', '\u003E', '\u061F', + // 0xC8 + '\u0628', '\u0629', '\u062A', '\u062B', '\u062C', '\u062D', '\u062E', '\u062F', - // 0xC0 - '\u274A', '\u0621', '\u0622', '\u0623', '\u0624', '\u0625', '\u0626', '\u0627', + // 0xD0 + '\u0630', '\u0631', '\u0632', '\u0633', '\u0634', '\u0635', '\u0636', '\u0637', - // 0xC8 - '\u0628', '\u0629', '\u062A', '\u062B', '\u062C', '\u062D', '\u062E', '\u062F', + // 0xD8 + '\u0638', '\u0639', '\u063A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0xD0 - '\u0630', '\u0631', '\u0632', '\u0633', '\u0634', '\u0635', '\u0636', '\u0637', + // 0xE0 + '\u0640', '\u0641', '\u0642', '\u0643', '\u0644', '\u0645', '\u0646', '\u0647', - // 0xD8 - '\u0638', '\u0639', '\u063A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0xE8 + '\u0648', '\u0649', '\u064A', '\u064B', '\u064C', '\u064D', '\u064E', '\u064F', - // 0xE0 - '\u0640', '\u0641', '\u0642', '\u0643', '\u0644', '\u0645', '\u0646', '\u0647', + // 0xF0 + '\u0650', '\u0651', '\u0652', '\u067E', '\u0679', '\u0686', '\u06D5', '\u06A4', - // 0xE8 - '\u0648', '\u0649', '\u064A', '\u064B', '\u064C', '\u064D', '\u064E', '\u064F', + // 0xF8 + '\u06AF', '\u0688', '\u0691', '\u007B', '\u007C', '\u007D', '\u0698', '\u06D2' + }; - // 0xF0 - '\u0650', '\u0651', '\u0652', '\u067E', '\u0679', '\u0686', '\u06D5', '\u06A4', - - // 0xF8 - '\u06AF', '\u0688', '\u0691', '\u007B', '\u007C', '\u007D', '\u0698', '\u06D2' - }; - - /// Converts a Unicode character to an Mac Farsi character - /// Mac Farsi character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\uF8FF' => 0x14, - '\u0014' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u00C4' => 0x80, - '\u00A0' => 0x81, - '\u00C7' => 0x82, - '\u00C9' => 0x83, - '\u00D1' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u00E1' => 0x87, - '\u00E0' => 0x88, - '\u00E2' => 0x89, - '\u00E4' => 0x8A, - '\u06BA' => 0x8B, - '\u00AB' => 0x8C, - '\u00E7' => 0x8D, - '\u00E9' => 0x8E, - '\u00E8' => 0x8F, - '\u00EA' => 0x90, - '\u00EB' => 0x91, - '\u00ED' => 0x92, - '\u2026' => 0x93, - '\u00EE' => 0x94, - '\u00EF' => 0x95, - '\u00F1' => 0x96, - '\u00F3' => 0x97, - '\u00BB' => 0x98, - '\u00F4' => 0x99, - '\u00F6' => 0x9A, - '\u00F7' => 0x9B, - '\u00FA' => 0x9C, - '\u00F9' => 0x9D, - '\u00FB' => 0x9E, - '\u00FC' => 0x9F, - '\u066A' => 0xA5, - '\u060C' => 0xAC, - '\u06F0' => 0xB0, - '\u06F1' => 0xB1, - '\u06F2' => 0xB2, - '\u06F3' => 0xB3, - '\u06F4' => 0xB4, - '\u06F5' => 0xB5, - '\u06F6' => 0xB6, - '\u06F7' => 0xB7, - '\u06F8' => 0xB8, - '\u06F9' => 0xB9, - '\u061B' => 0xBB, - '\u061F' => 0xBF, - '\u274A' => 0xC0, - '\u0621' => 0xC1, - '\u0622' => 0xC2, - '\u0623' => 0xC3, - '\u0624' => 0xC4, - '\u0625' => 0xC5, - '\u0626' => 0xC6, - '\u0627' => 0xC7, - '\u0628' => 0xC8, - '\u0629' => 0xC9, - '\u062A' => 0xCA, - '\u062B' => 0xCB, - '\u062C' => 0xCC, - '\u062D' => 0xCD, - '\u062E' => 0xCE, - '\u062F' => 0xCF, - '\u0630' => 0xD0, - '\u0631' => 0xD1, - '\u0632' => 0xD2, - '\u0633' => 0xD3, - '\u0634' => 0xD4, - '\u0635' => 0xD5, - '\u0636' => 0xD6, - '\u0637' => 0xD7, - '\u0638' => 0xD8, - '\u0639' => 0xD9, - '\u063A' => 0xDA, - '\u0640' => 0xE0, - '\u0641' => 0xE1, - '\u0642' => 0xE2, - '\u0643' => 0xE3, - '\u0644' => 0xE4, - '\u0645' => 0xE5, - '\u0646' => 0xE6, - '\u0647' => 0xE7, - '\u0648' => 0xE8, - '\u0649' => 0xE9, - '\u064A' => 0xEA, - '\u064B' => 0xEB, - '\u064C' => 0xEC, - '\u064D' => 0xED, - '\u064E' => 0xEE, - '\u064F' => 0xEF, - '\u0650' => 0xF0, - '\u0651' => 0xF1, - '\u0652' => 0xF2, - '\u067E' => 0xF3, - '\u0679' => 0xF4, - '\u0686' => 0xF5, - '\u06D5' => 0xF6, - '\u06A4' => 0xF7, - '\u06AF' => 0xF8, - '\u0688' => 0xF9, - '\u0691' => 0xFA, - '\u0698' => 0xFE, - '\u06D2' => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Mac Farsi character + /// Mac Farsi character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\uF8FF' => 0x14, + '\u0014' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u00C4' => 0x80, + '\u00A0' => 0x81, + '\u00C7' => 0x82, + '\u00C9' => 0x83, + '\u00D1' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u00E1' => 0x87, + '\u00E0' => 0x88, + '\u00E2' => 0x89, + '\u00E4' => 0x8A, + '\u06BA' => 0x8B, + '\u00AB' => 0x8C, + '\u00E7' => 0x8D, + '\u00E9' => 0x8E, + '\u00E8' => 0x8F, + '\u00EA' => 0x90, + '\u00EB' => 0x91, + '\u00ED' => 0x92, + '\u2026' => 0x93, + '\u00EE' => 0x94, + '\u00EF' => 0x95, + '\u00F1' => 0x96, + '\u00F3' => 0x97, + '\u00BB' => 0x98, + '\u00F4' => 0x99, + '\u00F6' => 0x9A, + '\u00F7' => 0x9B, + '\u00FA' => 0x9C, + '\u00F9' => 0x9D, + '\u00FB' => 0x9E, + '\u00FC' => 0x9F, + '\u066A' => 0xA5, + '\u060C' => 0xAC, + '\u06F0' => 0xB0, + '\u06F1' => 0xB1, + '\u06F2' => 0xB2, + '\u06F3' => 0xB3, + '\u06F4' => 0xB4, + '\u06F5' => 0xB5, + '\u06F6' => 0xB6, + '\u06F7' => 0xB7, + '\u06F8' => 0xB8, + '\u06F9' => 0xB9, + '\u061B' => 0xBB, + '\u061F' => 0xBF, + '\u274A' => 0xC0, + '\u0621' => 0xC1, + '\u0622' => 0xC2, + '\u0623' => 0xC3, + '\u0624' => 0xC4, + '\u0625' => 0xC5, + '\u0626' => 0xC6, + '\u0627' => 0xC7, + '\u0628' => 0xC8, + '\u0629' => 0xC9, + '\u062A' => 0xCA, + '\u062B' => 0xCB, + '\u062C' => 0xCC, + '\u062D' => 0xCD, + '\u062E' => 0xCE, + '\u062F' => 0xCF, + '\u0630' => 0xD0, + '\u0631' => 0xD1, + '\u0632' => 0xD2, + '\u0633' => 0xD3, + '\u0634' => 0xD4, + '\u0635' => 0xD5, + '\u0636' => 0xD6, + '\u0637' => 0xD7, + '\u0638' => 0xD8, + '\u0639' => 0xD9, + '\u063A' => 0xDA, + '\u0640' => 0xE0, + '\u0641' => 0xE1, + '\u0642' => 0xE2, + '\u0643' => 0xE3, + '\u0644' => 0xE4, + '\u0645' => 0xE5, + '\u0646' => 0xE6, + '\u0647' => 0xE7, + '\u0648' => 0xE8, + '\u0649' => 0xE9, + '\u064A' => 0xEA, + '\u064B' => 0xEB, + '\u064C' => 0xEC, + '\u064D' => 0xED, + '\u064E' => 0xEE, + '\u064F' => 0xEF, + '\u0650' => 0xF0, + '\u0651' => 0xF1, + '\u0652' => 0xF2, + '\u067E' => 0xF3, + '\u0679' => 0xF4, + '\u0686' => 0xF5, + '\u06D5' => 0xF6, + '\u06A4' => 0xF7, + '\u06AF' => 0xF8, + '\u0688' => 0xF9, + '\u0691' => 0xFA, + '\u0698' => 0xFE, + '\u06D2' => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacGreek.cs b/Claunia.Encoding/MacGreek.cs index cd1f918..b1f5f0f 100644 --- a/Claunia.Encoding/MacGreek.cs +++ b/Claunia.Encoding/MacGreek.cs @@ -24,402 +24,401 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Mac Greek character encoding of Unicode characters. +public class MacGreek : SingleByteEncoding { - /// Represents an Mac Greek character encoding of Unicode characters. - public class MacGreek : SingleByteEncoding + /// + public override string BodyName => "x-mac-greek"; + /// + public override int CodePage => 10006; + /// + public override string EncodingName => "Greek (Mac)"; + /// + public override string HeaderName => "x-mac-greek"; + /// + public override string WebName => "x-mac-greek"; + /// + public override int WindowsCodePage => 10006; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Macintosh Greek to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "x-mac-greek"; - /// - public override int CodePage => 10006; - /// - public override string EncodingName => "Greek (Mac)"; - /// - public override string HeaderName => "x-mac-greek"; - /// - public override string WebName => "x-mac-greek"; - /// - public override int WindowsCodePage => 10006; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Macintosh Greek to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u00C4', '\u00B9', '\u00B2', '\u00C9', '\u00B3', '\u00D6', '\u00DC', '\u0385', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u00E0', '\u00E2', '\u00E4', '\u0384', '\u00A8', '\u00E7', '\u00E9', '\u00E8', - // 0x80 - '\u00C4', '\u00B9', '\u00B2', '\u00C9', '\u00B3', '\u00D6', '\u00DC', '\u0385', + // 0x90 + '\u00EA', '\u00EB', '\u00A3', '\u2122', '\u00EE', '\u00EF', '\u2022', '\u00BD', - // 0x88 - '\u00E0', '\u00E2', '\u00E4', '\u0384', '\u00A8', '\u00E7', '\u00E9', '\u00E8', + // 0x98 + '\u2030', '\u00F4', '\u00F6', '\u00A6', '\u20AC', '\u00F9', '\u00FB', '\u00FC', - // 0x90 - '\u00EA', '\u00EB', '\u00A3', '\u2122', '\u00EE', '\u00EF', '\u2022', '\u00BD', + // 0xA0 + '\u2020', '\u0393', '\u0394', '\u0398', '\u039B', '\u039E', '\u03A0', '\u00DF', - // 0x98 - '\u2030', '\u00F4', '\u00F6', '\u00A6', '\u20AC', '\u00F9', '\u00FB', '\u00FC', + // 0xA8 + '\u00AE', '\u00A9', '\u03A3', '\u03AA', '\u00A7', '\u2260', '\u00B0', '\u00B7', - // 0xA0 - '\u2020', '\u0393', '\u0394', '\u0398', '\u039B', '\u039E', '\u03A0', '\u00DF', + // 0xB0 + '\u0391', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u0392', '\u0395', '\u0396', - // 0xA8 - '\u00AE', '\u00A9', '\u03A3', '\u03AA', '\u00A7', '\u2260', '\u00B0', '\u00B7', + // 0xB8 + '\u0397', '\u0399', '\u039A', '\u039C', '\u03A6', '\u03AB', '\u03A8', '\u03A9', - // 0xB0 - '\u0391', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u0392', '\u0395', '\u0396', + // 0xC0 + '\u03AC', '\u039D', '\u00AC', '\u039F', '\u03A1', '\u2248', '\u03A4', '\u00AB', - // 0xB8 - '\u0397', '\u0399', '\u039A', '\u039C', '\u03A6', '\u03AB', '\u03A8', '\u03A9', + // 0xC8 + '\u00BB', '\u2026', '\u00A0', '\u03A5', '\u03A7', '\u0386', '\u0388', '\u0153', - // 0xC0 - '\u03AC', '\u039D', '\u00AC', '\u039F', '\u03A1', '\u2248', '\u03A4', '\u00AB', + // 0xD0 + '\u2013', '\u2015', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u0389', - // 0xC8 - '\u00BB', '\u2026', '\u00A0', '\u03A5', '\u03A7', '\u0386', '\u0388', '\u0153', + // 0xD8 + '\u038A', '\u038C', '\u038E', '\u03AD', '\u03AE', '\u03AF', '\u03CC', '\u038F', - // 0xD0 - '\u2013', '\u2015', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u0389', + // 0xE0 + '\u03CD', '\u03B1', '\u03B2', '\u03C8', '\u03B4', '\u03B5', '\u03C6', '\u03B3', - // 0xD8 - '\u038A', '\u038C', '\u038E', '\u03AD', '\u03AE', '\u03AF', '\u03CC', '\u038F', + // 0xE8 + '\u03B7', '\u03B9', '\u03BE', '\u03BA', '\u03BB', '\u03BC', '\u03BD', '\u03BF', - // 0xE0 - '\u03CD', '\u03B1', '\u03B2', '\u03C8', '\u03B4', '\u03B5', '\u03C6', '\u03B3', + // 0xF0 + '\u03C0', '\u03CE', '\u03C1', '\u03C3', '\u03C4', '\u03B8', '\u03C9', '\u03C2', - // 0xE8 - '\u03B7', '\u03B9', '\u03BE', '\u03BA', '\u03BB', '\u03BC', '\u03BD', '\u03BF', + // 0xF8 + '\u03C7', '\u03C5', '\u03B6', '\u03CA', '\u03CB', '\u0390', '\u03B0', '\u00AD' + }; - // 0xF0 - '\u03C0', '\u03CE', '\u03C1', '\u03C3', '\u03C4', '\u03B8', '\u03C9', '\u03C2', - - // 0xF8 - '\u03C7', '\u03C5', '\u03B6', '\u03CA', '\u03CB', '\u0390', '\u03B0', '\u00AD' - }; - - /// Converts a Unicode character to an Mac Greek character - /// Mac Greek character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\u0014' => 0x14, - '\uF8FF' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u00C4' => 0x80, - '\u00B9' => 0x81, - '\u00B2' => 0x82, - '\u00C9' => 0x83, - '\u00B3' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u0385' => 0x87, - '\u00E0' => 0x88, - '\u00E2' => 0x89, - '\u00E4' => 0x8A, - '\u0384' => 0x8B, - '\u00A8' => 0x8C, - '\u00E7' => 0x8D, - '\u00E9' => 0x8E, - '\u00E8' => 0x8F, - '\u00EA' => 0x90, - '\u00EB' => 0x91, - '\u00A3' => 0x92, - '\u2122' => 0x93, - '\u00EE' => 0x94, - '\u00EF' => 0x95, - '\u2022' => 0x96, - '\u00BD' => 0x97, - '\u2030' => 0x98, - '\u00F4' => 0x99, - '\u00F6' => 0x9A, - '\u00A6' => 0x9B, - '\u20AC' => 0x9C, - '\u00F9' => 0x9D, - '\u00FB' => 0x9E, - '\u00FC' => 0x9F, - '\u2020' => 0xA0, - '\u0393' => 0xA1, - '\u0394' => 0xA2, - '\u0398' => 0xA3, - '\u039B' => 0xA4, - '\u039E' => 0xA5, - '\u03A0' => 0xA6, - '\u00DF' => 0xA7, - '\u00AE' => 0xA8, - '\u00A9' => 0xA9, - '\u03A3' => 0xAA, - '\u03AA' => 0xAB, - '\u00A7' => 0xAC, - '\u2260' => 0xAD, - '\u00B0' => 0xAE, - '\u00B7' => 0xAF, - '\u0391' => 0xB0, - '\u00B1' => 0xB1, - '\u2264' => 0xB2, - '\u2265' => 0xB3, - '\u00A5' => 0xB4, - '\u0392' => 0xB5, - '\u0395' => 0xB6, - '\u0396' => 0xB7, - '\u0397' => 0xB8, - '\u0399' => 0xB9, - '\u039A' => 0xBA, - '\u039C' => 0xBB, - '\u03A6' => 0xBC, - '\u03AB' => 0xBD, - '\u03A8' => 0xBE, - '\u03A9' => 0xBF, - '\u03AC' => 0xC0, - '\u039D' => 0xC1, - '\u00AC' => 0xC2, - '\u039F' => 0xC3, - '\u03A1' => 0xC4, - '\u2248' => 0xC5, - '\u03A4' => 0xC6, - '\u00AB' => 0xC7, - '\u00BB' => 0xC8, - '\u2026' => 0xC9, - '\u00A0' => 0xCA, - '\u03A5' => 0xCB, - '\u03A7' => 0xCC, - '\u0386' => 0xCD, - '\u0388' => 0xCE, - '\u0153' => 0xCF, - '\u2013' => 0xD0, - '\u2015' => 0xD1, - '\u201C' => 0xD2, - '\u201D' => 0xD3, - '\u2018' => 0xD4, - '\u2019' => 0xD5, - '\u00F7' => 0xD6, - '\u0389' => 0xD7, - '\u038A' => 0xD8, - '\u038C' => 0xD9, - '\u038E' => 0xDA, - '\u03AD' => 0xDB, - '\u03AE' => 0xDC, - '\u03AF' => 0xDD, - '\u03CC' => 0xDE, - '\u038F' => 0xDF, - '\u03CD' => 0xE0, - '\u03B1' => 0xE1, - '\u03B2' => 0xE2, - '\u03C8' => 0xE3, - '\u03B4' => 0xE4, - '\u03B5' => 0xE5, - '\u03C6' => 0xE6, - '\u03B3' => 0xE7, - '\u03B7' => 0xE8, - '\u03B9' => 0xE9, - '\u03BE' => 0xEA, - '\u03BA' => 0xEB, - '\u03BB' => 0xEC, - '\u03BC' => 0xED, - '\u03BD' => 0xEE, - '\u03BF' => 0xEF, - '\u03C0' => 0xF0, - '\u03CE' => 0xF1, - '\u03C1' => 0xF2, - '\u03C3' => 0xF3, - '\u03C4' => 0xF4, - '\u03B8' => 0xF5, - '\u03C9' => 0xF6, - '\u03C2' => 0xF7, - '\u03C7' => 0xF8, - '\u03C5' => 0xF9, - '\u03B6' => 0xFA, - '\u03CA' => 0xFB, - '\u03CB' => 0xFC, - '\u0390' => 0xFD, - '\u03B0' => 0xFE, - '\u00AD' => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Mac Greek character + /// Mac Greek character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\u0014' => 0x14, + '\uF8FF' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u00C4' => 0x80, + '\u00B9' => 0x81, + '\u00B2' => 0x82, + '\u00C9' => 0x83, + '\u00B3' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u0385' => 0x87, + '\u00E0' => 0x88, + '\u00E2' => 0x89, + '\u00E4' => 0x8A, + '\u0384' => 0x8B, + '\u00A8' => 0x8C, + '\u00E7' => 0x8D, + '\u00E9' => 0x8E, + '\u00E8' => 0x8F, + '\u00EA' => 0x90, + '\u00EB' => 0x91, + '\u00A3' => 0x92, + '\u2122' => 0x93, + '\u00EE' => 0x94, + '\u00EF' => 0x95, + '\u2022' => 0x96, + '\u00BD' => 0x97, + '\u2030' => 0x98, + '\u00F4' => 0x99, + '\u00F6' => 0x9A, + '\u00A6' => 0x9B, + '\u20AC' => 0x9C, + '\u00F9' => 0x9D, + '\u00FB' => 0x9E, + '\u00FC' => 0x9F, + '\u2020' => 0xA0, + '\u0393' => 0xA1, + '\u0394' => 0xA2, + '\u0398' => 0xA3, + '\u039B' => 0xA4, + '\u039E' => 0xA5, + '\u03A0' => 0xA6, + '\u00DF' => 0xA7, + '\u00AE' => 0xA8, + '\u00A9' => 0xA9, + '\u03A3' => 0xAA, + '\u03AA' => 0xAB, + '\u00A7' => 0xAC, + '\u2260' => 0xAD, + '\u00B0' => 0xAE, + '\u00B7' => 0xAF, + '\u0391' => 0xB0, + '\u00B1' => 0xB1, + '\u2264' => 0xB2, + '\u2265' => 0xB3, + '\u00A5' => 0xB4, + '\u0392' => 0xB5, + '\u0395' => 0xB6, + '\u0396' => 0xB7, + '\u0397' => 0xB8, + '\u0399' => 0xB9, + '\u039A' => 0xBA, + '\u039C' => 0xBB, + '\u03A6' => 0xBC, + '\u03AB' => 0xBD, + '\u03A8' => 0xBE, + '\u03A9' => 0xBF, + '\u03AC' => 0xC0, + '\u039D' => 0xC1, + '\u00AC' => 0xC2, + '\u039F' => 0xC3, + '\u03A1' => 0xC4, + '\u2248' => 0xC5, + '\u03A4' => 0xC6, + '\u00AB' => 0xC7, + '\u00BB' => 0xC8, + '\u2026' => 0xC9, + '\u00A0' => 0xCA, + '\u03A5' => 0xCB, + '\u03A7' => 0xCC, + '\u0386' => 0xCD, + '\u0388' => 0xCE, + '\u0153' => 0xCF, + '\u2013' => 0xD0, + '\u2015' => 0xD1, + '\u201C' => 0xD2, + '\u201D' => 0xD3, + '\u2018' => 0xD4, + '\u2019' => 0xD5, + '\u00F7' => 0xD6, + '\u0389' => 0xD7, + '\u038A' => 0xD8, + '\u038C' => 0xD9, + '\u038E' => 0xDA, + '\u03AD' => 0xDB, + '\u03AE' => 0xDC, + '\u03AF' => 0xDD, + '\u03CC' => 0xDE, + '\u038F' => 0xDF, + '\u03CD' => 0xE0, + '\u03B1' => 0xE1, + '\u03B2' => 0xE2, + '\u03C8' => 0xE3, + '\u03B4' => 0xE4, + '\u03B5' => 0xE5, + '\u03C6' => 0xE6, + '\u03B3' => 0xE7, + '\u03B7' => 0xE8, + '\u03B9' => 0xE9, + '\u03BE' => 0xEA, + '\u03BA' => 0xEB, + '\u03BB' => 0xEC, + '\u03BC' => 0xED, + '\u03BD' => 0xEE, + '\u03BF' => 0xEF, + '\u03C0' => 0xF0, + '\u03CE' => 0xF1, + '\u03C1' => 0xF2, + '\u03C3' => 0xF3, + '\u03C4' => 0xF4, + '\u03B8' => 0xF5, + '\u03C9' => 0xF6, + '\u03C2' => 0xF7, + '\u03C7' => 0xF8, + '\u03C5' => 0xF9, + '\u03B6' => 0xFA, + '\u03CA' => 0xFB, + '\u03CB' => 0xFC, + '\u0390' => 0xFD, + '\u03B0' => 0xFE, + '\u00AD' => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacHebrew.cs b/Claunia.Encoding/MacHebrew.cs index ec58036..d2842d5 100644 --- a/Claunia.Encoding/MacHebrew.cs +++ b/Claunia.Encoding/MacHebrew.cs @@ -24,367 +24,366 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Mac Hebrew character encoding of Unicode characters. +public class MacHebrew : SingleByteEncoding { - /// Represents an Mac Hebrew character encoding of Unicode characters. - public class MacHebrew : SingleByteEncoding + /// + public override string BodyName => "x-mac-hebrew"; + /// + public override int CodePage => 10005; + /// + public override string EncodingName => "Hebrew (Mac)"; + /// + public override string HeaderName => "x-mac-hebrew"; + /// + public override string WebName => "x-mac-hebrew"; + /// + public override int WindowsCodePage => 10005; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Macintosh Hebrew to Unicode character map. + + // TODO: 0x81 => 0x05F2+0x05B7 + // TODO: 0xC0 => 0xF86A+0x05DC+0x05B9 + // TODO: 0xDE => 0x05B8+0xF87F + protected override char[] CharTable => new[] { - /// - public override string BodyName => "x-mac-hebrew"; - /// - public override int CodePage => 10005; - /// - public override string EncodingName => "Hebrew (Mac)"; - /// - public override string HeaderName => "x-mac-hebrew"; - /// - public override string WebName => "x-mac-hebrew"; - /// - public override int WindowsCodePage => 10005; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Macintosh Hebrew to Unicode character map. + // 0x10 + '\u0010', '\u0011', '\u0012', '\u0013', '\uF8FF', '\u0015', '\u0016', '\u0017', - // TODO: 0x81 => 0x05F2+0x05B7 - // TODO: 0xC0 => 0xF86A+0x05DC+0x05B9 - // TODO: 0xDE => 0x05B8+0xF87F - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x10 - '\u0010', '\u0011', '\u0012', '\u0013', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x80 + '\u00C4', '\u0081', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x88 + '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x90 + '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', - // 0x80 - '\u00C4', '\u0081', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', + // 0x98 + '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', - // 0x88 - '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', + // 0xA0 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u20AA', '\u0027', - // 0x90 - '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', + // 0xA8 + '\u0029', '\u0028', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x98 - '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', + // 0xB0 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0xA0 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u20AA', '\u0027', + // 0xB8 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0xA8 - '\u0029', '\u0028', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0xC0 + '\uF86A', '\u201E', '\uF89B', '\uF89C', '\uF89D', '\uF89E', '\u05BC', '\uFB4B', - // 0xB0 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0xC8 + '\uFB35', '\u2026', '\u00A0', '\u05B8', '\u05B7', '\u05B5', '\u05B6', '\u05B4', - // 0xB8 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0xD0 + '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\uFB2A', '\uFB2B', - // 0xC0 - '\uF86A', '\u201E', '\uF89B', '\uF89C', '\uF89D', '\uF89E', '\u05BC', '\uFB4B', + // 0xD8 + '\u05BF', '\u05B0', '\u05B2', '\u05B1', '\u05BB', '\u05B9', '\u05B8', '\u05B3', - // 0xC8 - '\uFB35', '\u2026', '\u00A0', '\u05B8', '\u05B7', '\u05B5', '\u05B6', '\u05B4', + // 0xE0 + '\u05D0', '\u05D1', '\u05D2', '\u05D3', '\u05D4', '\u05D5', '\u05D6', '\u05D7', - // 0xD0 - '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\uFB2A', '\uFB2B', + // 0xE8 + '\u05D8', '\u05D9', '\u05DA', '\u05DB', '\u05DC', '\u05DD', '\u05DE', '\u05DF', - // 0xD8 - '\u05BF', '\u05B0', '\u05B2', '\u05B1', '\u05BB', '\u05B9', '\u05B8', '\u05B3', + // 0xF0 + '\u05E0', '\u05E1', '\u05E2', '\u05E3', '\u05E4', '\u05E5', '\u05E6', '\u05E7', - // 0xE0 - '\u05D0', '\u05D1', '\u05D2', '\u05D3', '\u05D4', '\u05D5', '\u05D6', '\u05D7', + // 0xF8 + '\u05E8', '\u05E9', '\u05EA', '\u007D', '\u005D', '\u007B', '\u005B', '\u007C' + }; - // 0xE8 - '\u05D8', '\u05D9', '\u05DA', '\u05DB', '\u05DC', '\u05DD', '\u05DE', '\u05DF', - - // 0xF0 - '\u05E0', '\u05E1', '\u05E2', '\u05E3', '\u05E4', '\u05E5', '\u05E6', '\u05E7', - - // 0xF8 - '\u05E8', '\u05E9', '\u05EA', '\u007D', '\u005D', '\u007B', '\u005B', '\u007C' - }; - - /// Converts a Unicode character to an Mac Hebrew character - /// Mac Hebrew character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\u0014' => 0x14, - '\uF8FF' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u00C4' => 0x80, - '\u00C7' => 0x82, - '\u00C9' => 0x83, - '\u00D1' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u00E1' => 0x87, - '\u00E0' => 0x88, - '\u00E2' => 0x89, - '\u00E4' => 0x8A, - '\u00E3' => 0x8B, - '\u00E5' => 0x8C, - '\u00E7' => 0x8D, - '\u00E9' => 0x8E, - '\u00E8' => 0x8F, - '\u00EA' => 0x90, - '\u00EB' => 0x91, - '\u00ED' => 0x92, - '\u00EC' => 0x93, - '\u00EE' => 0x94, - '\u00EF' => 0x95, - '\u00F1' => 0x96, - '\u00F3' => 0x97, - '\u00F2' => 0x98, - '\u00F4' => 0x99, - '\u00F6' => 0x9A, - '\u00F5' => 0x9B, - '\u00FA' => 0x9C, - '\u00F9' => 0x9D, - '\u00FB' => 0x9E, - '\u00FC' => 0x9F, - '\u20AA' => 0xA6, - '\u201E' => 0xC1, - '\uF89B' => 0xC2, - '\uF89C' => 0xC3, - '\uF89D' => 0xC4, - '\uF89E' => 0xC5, - '\u05BC' => 0xC6, - '\uFB4B' => 0xC7, - '\uFB35' => 0xC8, - '\u2026' => 0xC9, - '\u00A0' => 0xCA, - '\u05B8' => 0xCB, - '\u05B7' => 0xCC, - '\u05B5' => 0xCD, - '\u05B6' => 0xCE, - '\u05B4' => 0xCF, - '\u2013' => 0xD0, - '\u2014' => 0xD1, - '\u201C' => 0xD2, - '\u201D' => 0xD3, - '\u2018' => 0xD4, - '\u2019' => 0xD5, - '\uFB2A' => 0xD6, - '\uFB2B' => 0xD7, - '\u05BF' => 0xD8, - '\u05B0' => 0xD9, - '\u05B2' => 0xDA, - '\u05B1' => 0xDB, - '\u05BB' => 0xDC, - '\u05B9' => 0xDD, - '\u05B3' => 0xDF, - '\u05D0' => 0xE0, - '\u05D1' => 0xE1, - '\u05D2' => 0xE2, - '\u05D3' => 0xE3, - '\u05D4' => 0xE4, - '\u05D5' => 0xE5, - '\u05D6' => 0xE6, - '\u05D7' => 0xE7, - '\u05D8' => 0xE8, - '\u05D9' => 0xE9, - '\u05DA' => 0xEA, - '\u05DB' => 0xEB, - '\u05DC' => 0xEC, - '\u05DD' => 0xED, - '\u05DE' => 0xEE, - '\u05DF' => 0xEF, - '\u05E0' => 0xF0, - '\u05E1' => 0xF1, - '\u05E2' => 0xF2, - '\u05E3' => 0xF3, - '\u05E4' => 0xF4, - '\u05E5' => 0xF5, - '\u05E6' => 0xF6, - '\u05E7' => 0xF7, - '\u05E8' => 0xF8, - '\u05E9' => 0xF9, - '\u05EA' => 0xFA, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Mac Hebrew character + /// Mac Hebrew character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\u0014' => 0x14, + '\uF8FF' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u00C4' => 0x80, + '\u00C7' => 0x82, + '\u00C9' => 0x83, + '\u00D1' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u00E1' => 0x87, + '\u00E0' => 0x88, + '\u00E2' => 0x89, + '\u00E4' => 0x8A, + '\u00E3' => 0x8B, + '\u00E5' => 0x8C, + '\u00E7' => 0x8D, + '\u00E9' => 0x8E, + '\u00E8' => 0x8F, + '\u00EA' => 0x90, + '\u00EB' => 0x91, + '\u00ED' => 0x92, + '\u00EC' => 0x93, + '\u00EE' => 0x94, + '\u00EF' => 0x95, + '\u00F1' => 0x96, + '\u00F3' => 0x97, + '\u00F2' => 0x98, + '\u00F4' => 0x99, + '\u00F6' => 0x9A, + '\u00F5' => 0x9B, + '\u00FA' => 0x9C, + '\u00F9' => 0x9D, + '\u00FB' => 0x9E, + '\u00FC' => 0x9F, + '\u20AA' => 0xA6, + '\u201E' => 0xC1, + '\uF89B' => 0xC2, + '\uF89C' => 0xC3, + '\uF89D' => 0xC4, + '\uF89E' => 0xC5, + '\u05BC' => 0xC6, + '\uFB4B' => 0xC7, + '\uFB35' => 0xC8, + '\u2026' => 0xC9, + '\u00A0' => 0xCA, + '\u05B8' => 0xCB, + '\u05B7' => 0xCC, + '\u05B5' => 0xCD, + '\u05B6' => 0xCE, + '\u05B4' => 0xCF, + '\u2013' => 0xD0, + '\u2014' => 0xD1, + '\u201C' => 0xD2, + '\u201D' => 0xD3, + '\u2018' => 0xD4, + '\u2019' => 0xD5, + '\uFB2A' => 0xD6, + '\uFB2B' => 0xD7, + '\u05BF' => 0xD8, + '\u05B0' => 0xD9, + '\u05B2' => 0xDA, + '\u05B1' => 0xDB, + '\u05BB' => 0xDC, + '\u05B9' => 0xDD, + '\u05B3' => 0xDF, + '\u05D0' => 0xE0, + '\u05D1' => 0xE1, + '\u05D2' => 0xE2, + '\u05D3' => 0xE3, + '\u05D4' => 0xE4, + '\u05D5' => 0xE5, + '\u05D6' => 0xE6, + '\u05D7' => 0xE7, + '\u05D8' => 0xE8, + '\u05D9' => 0xE9, + '\u05DA' => 0xEA, + '\u05DB' => 0xEB, + '\u05DC' => 0xEC, + '\u05DD' => 0xED, + '\u05DE' => 0xEE, + '\u05DF' => 0xEF, + '\u05E0' => 0xF0, + '\u05E1' => 0xF1, + '\u05E2' => 0xF2, + '\u05E3' => 0xF3, + '\u05E4' => 0xF4, + '\u05E5' => 0xF5, + '\u05E6' => 0xF6, + '\u05E7' => 0xF7, + '\u05E8' => 0xF8, + '\u05E9' => 0xF9, + '\u05EA' => 0xFA, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacRoman.cs b/Claunia.Encoding/MacRoman.cs index 1edc120..5ccc2b0 100644 --- a/Claunia.Encoding/MacRoman.cs +++ b/Claunia.Encoding/MacRoman.cs @@ -24,402 +24,401 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Apple Mac character encoding of Unicode characters. +public class MacRoman : SingleByteEncoding { - /// Represents an Apple Mac character encoding of Unicode characters. - public class MacRoman : SingleByteEncoding + /// + public override string BodyName => "macintosh"; + /// + public override int CodePage => 10000; + /// + public override string EncodingName => "Western European (Mac)"; + /// + public override string HeaderName => "macintosh"; + /// + public override string WebName => "macintosh"; + /// + public override int WindowsCodePage => 10000; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Mac to Unicode character map. MacRoman is a superset of LisaRoman. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "macintosh"; - /// - public override int CodePage => 10000; - /// - public override string EncodingName => "Western European (Mac)"; - /// - public override string HeaderName => "macintosh"; - /// - public override string WebName => "macintosh"; - /// - public override int WindowsCodePage => 10000; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Mac to Unicode character map. MacRoman is a superset of LisaRoman. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', - // 0x80 - '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', + // 0x90 + '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', - // 0x88 - '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', + // 0x98 + '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', - // 0x90 - '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', + // 0xA0 + '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', - // 0x98 - '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', + // 0xA8 + '\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8', - // 0xA0 - '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', + // 0xB0 + '\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211', - // 0xA8 - '\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8', + // 0xB8 + '\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8', - // 0xB0 - '\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211', + // 0xC0 + '\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', - // 0xB8 - '\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8', + // 0xC8 + '\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', - // 0xC0 - '\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', + // 0xD0 + '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', - // 0xC8 - '\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', + // 0xD8 + '\u00FF', '\u0178', '\u2044', '\u20AC', '\u2039', '\u203A', '\uFB01', '\uFB02', - // 0xD0 - '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', + // 0xE0 + '\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1', - // 0xD8 - '\u00FF', '\u0178', '\u2044', '\u20AC', '\u2039', '\u203A', '\uFB01', '\uFB02', + // 0xE8 + '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', - // 0xE0 - '\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1', + // 0xF0 + '\uF8FF', '\u00D2', '\u00DA', '\u00DB', '\u00D9', '\u0131', '\u02C6', '\u02DC', - // 0xE8 - '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', + // 0xF8 + '\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7' + }; - // 0xF0 - '\uF8FF', '\u00D2', '\u00DA', '\u00DB', '\u00D9', '\u0131', '\u02C6', '\u02DC', - - // 0xF8 - '\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7' - }; - - /// Converts a Unicode character to an MacRoman character - /// MacRoman character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u0011' => 0x11, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\u0014' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u00C4' => 0x80, - '\u00C5' => 0x81, - '\u00C7' => 0x82, - '\u00C9' => 0x83, - '\u00D1' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u00E1' => 0x87, - '\u00E0' => 0x88, - '\u00E2' => 0x89, - '\u00E4' => 0x8A, - '\u00E3' => 0x8B, - '\u00E5' => 0x8C, - '\u00E7' => 0x8D, - '\u00E9' => 0x8E, - '\u00E8' => 0x8F, - '\u00EA' => 0x90, - '\u00EB' => 0x91, - '\u00ED' => 0x92, - '\u00EC' => 0x93, - '\u00EE' => 0x94, - '\u00EF' => 0x95, - '\u00F1' => 0x96, - '\u00F3' => 0x97, - '\u00F2' => 0x98, - '\u00F4' => 0x99, - '\u00F6' => 0x9A, - '\u00F5' => 0x9B, - '\u00FA' => 0x9C, - '\u00F9' => 0x9D, - '\u00FB' => 0x9E, - '\u00FC' => 0x9F, - '\u2020' => 0xA0, - '\u00B0' => 0xA1, - '\u00A2' => 0xA2, - '\u00A3' => 0xA3, - '\u00A7' => 0xA4, - '\u2022' => 0xA5, - '\u00B6' => 0xA6, - '\u00DF' => 0xA7, - '\u00AE' => 0xA8, - '\u00A9' => 0xA9, - '\u2122' => 0xAA, - '\u00B4' => 0xAB, - '\u00A8' => 0xAC, - '\u2260' => 0xAD, - '\u00C6' => 0xAE, - '\u00D8' => 0xAF, - '\u221E' => 0xB0, - '\u00B1' => 0xB1, - '\u2264' => 0xB2, - '\u2265' => 0xB3, - '\u00A5' => 0xB4, - '\u00B5' => 0xB5, - '\u2202' => 0xB6, - '\u2211' => 0xB7, - '\u220F' => 0xB8, - '\u03C0' => 0xB9, - '\u222B' => 0xBA, - '\u00AA' => 0xBB, - '\u00BA' => 0xBC, - '\u03A9' => 0xBD, - '\u00E6' => 0xBE, - '\u00F8' => 0xBF, - '\u00BF' => 0xC0, - '\u00A1' => 0xC1, - '\u00AC' => 0xC2, - '\u221A' => 0xC3, - '\u0192' => 0xC4, - '\u2248' => 0xC5, - '\u2206' => 0xC6, - '\u00AB' => 0xC7, - '\u00BB' => 0xC8, - '\u2026' => 0xC9, - '\u00A0' => 0xCA, - '\u00C0' => 0xCB, - '\u00C3' => 0xCC, - '\u00D5' => 0xCD, - '\u0152' => 0xCE, - '\u0153' => 0xCF, - '\u2013' => 0xD0, - '\u2014' => 0xD1, - '\u201C' => 0xD2, - '\u201D' => 0xD3, - '\u2018' => 0xD4, - '\u2019' => 0xD5, - '\u00F7' => 0xD6, - '\u25CA' => 0xD7, - '\u00FF' => 0xD8, - '\u0178' => 0xD9, - '\u2044' => 0xDA, - '\u20AC' => 0xDB, - '\u2039' => 0xDC, - '\u203A' => 0xDD, - '\uFB01' => 0xDE, - '\uFB02' => 0xDF, - '\u2021' => 0xE0, - '\u00B7' => 0xE1, - '\u201A' => 0xE2, - '\u201E' => 0xE3, - '\u2030' => 0xE4, - '\u00C2' => 0xE5, - '\u00CA' => 0xE6, - '\u00C1' => 0xE7, - '\u00CB' => 0xE8, - '\u00C8' => 0xE9, - '\u00CD' => 0xEA, - '\u00CE' => 0xEB, - '\u00CF' => 0xEC, - '\u00CC' => 0xED, - '\u00D3' => 0xEE, - '\u00D4' => 0xEF, - '\uF8FF' => 0xF0, - '\u00D2' => 0xF1, - '\u00DA' => 0xF2, - '\u00DB' => 0xF3, - '\u00D9' => 0xF4, - '\u0131' => 0xF5, - '\u02C6' => 0xF6, - '\u02DC' => 0xF7, - '\u00AF' => 0xF8, - '\u02D8' => 0xF9, - '\u02D9' => 0xFA, - '\u02DA' => 0xFB, - '\u00B8' => 0xFC, - '\u02DD' => 0xFD, - '\u02DB' => 0xFE, - '\u02C7' => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an MacRoman character + /// MacRoman character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u0011' => 0x11, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\u0014' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u00C4' => 0x80, + '\u00C5' => 0x81, + '\u00C7' => 0x82, + '\u00C9' => 0x83, + '\u00D1' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u00E1' => 0x87, + '\u00E0' => 0x88, + '\u00E2' => 0x89, + '\u00E4' => 0x8A, + '\u00E3' => 0x8B, + '\u00E5' => 0x8C, + '\u00E7' => 0x8D, + '\u00E9' => 0x8E, + '\u00E8' => 0x8F, + '\u00EA' => 0x90, + '\u00EB' => 0x91, + '\u00ED' => 0x92, + '\u00EC' => 0x93, + '\u00EE' => 0x94, + '\u00EF' => 0x95, + '\u00F1' => 0x96, + '\u00F3' => 0x97, + '\u00F2' => 0x98, + '\u00F4' => 0x99, + '\u00F6' => 0x9A, + '\u00F5' => 0x9B, + '\u00FA' => 0x9C, + '\u00F9' => 0x9D, + '\u00FB' => 0x9E, + '\u00FC' => 0x9F, + '\u2020' => 0xA0, + '\u00B0' => 0xA1, + '\u00A2' => 0xA2, + '\u00A3' => 0xA3, + '\u00A7' => 0xA4, + '\u2022' => 0xA5, + '\u00B6' => 0xA6, + '\u00DF' => 0xA7, + '\u00AE' => 0xA8, + '\u00A9' => 0xA9, + '\u2122' => 0xAA, + '\u00B4' => 0xAB, + '\u00A8' => 0xAC, + '\u2260' => 0xAD, + '\u00C6' => 0xAE, + '\u00D8' => 0xAF, + '\u221E' => 0xB0, + '\u00B1' => 0xB1, + '\u2264' => 0xB2, + '\u2265' => 0xB3, + '\u00A5' => 0xB4, + '\u00B5' => 0xB5, + '\u2202' => 0xB6, + '\u2211' => 0xB7, + '\u220F' => 0xB8, + '\u03C0' => 0xB9, + '\u222B' => 0xBA, + '\u00AA' => 0xBB, + '\u00BA' => 0xBC, + '\u03A9' => 0xBD, + '\u00E6' => 0xBE, + '\u00F8' => 0xBF, + '\u00BF' => 0xC0, + '\u00A1' => 0xC1, + '\u00AC' => 0xC2, + '\u221A' => 0xC3, + '\u0192' => 0xC4, + '\u2248' => 0xC5, + '\u2206' => 0xC6, + '\u00AB' => 0xC7, + '\u00BB' => 0xC8, + '\u2026' => 0xC9, + '\u00A0' => 0xCA, + '\u00C0' => 0xCB, + '\u00C3' => 0xCC, + '\u00D5' => 0xCD, + '\u0152' => 0xCE, + '\u0153' => 0xCF, + '\u2013' => 0xD0, + '\u2014' => 0xD1, + '\u201C' => 0xD2, + '\u201D' => 0xD3, + '\u2018' => 0xD4, + '\u2019' => 0xD5, + '\u00F7' => 0xD6, + '\u25CA' => 0xD7, + '\u00FF' => 0xD8, + '\u0178' => 0xD9, + '\u2044' => 0xDA, + '\u20AC' => 0xDB, + '\u2039' => 0xDC, + '\u203A' => 0xDD, + '\uFB01' => 0xDE, + '\uFB02' => 0xDF, + '\u2021' => 0xE0, + '\u00B7' => 0xE1, + '\u201A' => 0xE2, + '\u201E' => 0xE3, + '\u2030' => 0xE4, + '\u00C2' => 0xE5, + '\u00CA' => 0xE6, + '\u00C1' => 0xE7, + '\u00CB' => 0xE8, + '\u00C8' => 0xE9, + '\u00CD' => 0xEA, + '\u00CE' => 0xEB, + '\u00CF' => 0xEC, + '\u00CC' => 0xED, + '\u00D3' => 0xEE, + '\u00D4' => 0xEF, + '\uF8FF' => 0xF0, + '\u00D2' => 0xF1, + '\u00DA' => 0xF2, + '\u00DB' => 0xF3, + '\u00D9' => 0xF4, + '\u0131' => 0xF5, + '\u02C6' => 0xF6, + '\u02DC' => 0xF7, + '\u00AF' => 0xF8, + '\u02D8' => 0xF9, + '\u02D9' => 0xFA, + '\u02DA' => 0xFB, + '\u00B8' => 0xFC, + '\u02DD' => 0xFD, + '\u02DB' => 0xFE, + '\u02C7' => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacRomanian.cs b/Claunia.Encoding/MacRomanian.cs index 1f420a7..8665875 100644 --- a/Claunia.Encoding/MacRomanian.cs +++ b/Claunia.Encoding/MacRomanian.cs @@ -24,401 +24,400 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Apple Mac character encoding of Unicode characters. +public class MacRomanian : SingleByteEncoding { - /// Represents an Apple Mac character encoding of Unicode characters. - public class MacRomanian : SingleByteEncoding + /// + public override string BodyName => "x-mac-romanian"; + /// + public override int CodePage => 10010; + /// + public override string EncodingName => "Romanianian (Mac)"; + /// + public override string HeaderName => "x-mac-romanian"; + /// + public override string WebName => "x-mac-romanian"; + /// + public override int WindowsCodePage => 10010; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Mac to Unicode character map. MacRomanian is a superset of MacRomanian. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "x-mac-romanian"; - /// - public override int CodePage => 10010; - /// - public override string EncodingName => "Romanianian (Mac)"; - /// - public override string HeaderName => "x-mac-romanian"; - /// - public override string WebName => "x-mac-romanian"; - /// - public override int WindowsCodePage => 10010; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Mac to Unicode character map. MacRomanian is a superset of MacRomanian. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', - // 0x80 - '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', + // 0x90 + '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', - // 0x88 - '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', + // 0x98 + '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', - // 0x90 - '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', + // 0xA0 + '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', - // 0x98 - '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', + // 0xA8 + '\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u0102', '\u0218', - // 0xA0 - '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', + // 0xB0 + '\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211', - // 0xA8 - '\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u0102', '\u0218', + // 0xB8 + '\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u0103', '\u0219', - // 0xB0 - '\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211', + // 0xC0 + '\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', - // 0xB8 - '\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u0103', '\u0219', + // 0xC8 + '\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', - // 0xC0 - '\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', + // 0xD0 + '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', - // 0xC8 - '\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', + // 0xD8 + '\u00FF', '\u0178', '\u2044', '\u20AC', '\u2039', '\u203A', '\u021A', '\u021B', - // 0xD0 - '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', + // 0xE0 + '\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1', - // 0xD8 - '\u00FF', '\u0178', '\u2044', '\u20AC', '\u2039', '\u203A', '\u021A', '\u021B', + // 0xE8 + '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', - // 0xE0 - '\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1', + // 0xF0 + '\uF8FF', '\u00D2', '\u00DA', '\u00DB', '\u00D9', '\u0131', '\u02C6', '\u02DC', - // 0xE8 - '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', + // 0xF8 + '\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7' + }; - // 0xF0 - '\uF8FF', '\u00D2', '\u00DA', '\u00DB', '\u00D9', '\u0131', '\u02C6', '\u02DC', - - // 0xF8 - '\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7' - }; - - /// Converts a Unicode character to an MacRomanian character - /// MacRomanian character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\u0014' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u00C4' => 0x80, - '\u00C5' => 0x81, - '\u00C7' => 0x82, - '\u00C9' => 0x83, - '\u00D1' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u00E1' => 0x87, - '\u00E0' => 0x88, - '\u00E2' => 0x89, - '\u00E4' => 0x8A, - '\u00E3' => 0x8B, - '\u00E5' => 0x8C, - '\u00E7' => 0x8D, - '\u00E9' => 0x8E, - '\u00E8' => 0x8F, - '\u00EA' => 0x90, - '\u00EB' => 0x91, - '\u00ED' => 0x92, - '\u00EC' => 0x93, - '\u00EE' => 0x94, - '\u00EF' => 0x95, - '\u00F1' => 0x96, - '\u00F3' => 0x97, - '\u00F2' => 0x98, - '\u00F4' => 0x99, - '\u00F6' => 0x9A, - '\u00F5' => 0x9B, - '\u00FA' => 0x9C, - '\u00F9' => 0x9D, - '\u00FB' => 0x9E, - '\u00FC' => 0x9F, - '\u2020' => 0xA0, - '\u00B0' => 0xA1, - '\u00A2' => 0xA2, - '\u00A3' => 0xA3, - '\u00A7' => 0xA4, - '\u2022' => 0xA5, - '\u00B6' => 0xA6, - '\u00DF' => 0xA7, - '\u00AE' => 0xA8, - '\u00A9' => 0xA9, - '\u2122' => 0xAA, - '\u00B4' => 0xAB, - '\u00A8' => 0xAC, - '\u2260' => 0xAD, - '\u0102' => 0xAE, - '\u0218' => 0xAF, - '\u221E' => 0xB0, - '\u00B1' => 0xB1, - '\u2264' => 0xB2, - '\u2265' => 0xB3, - '\u00A5' => 0xB4, - '\u00B5' => 0xB5, - '\u2202' => 0xB6, - '\u2211' => 0xB7, - '\u220F' => 0xB8, - '\u03C0' => 0xB9, - '\u222B' => 0xBA, - '\u00AA' => 0xBB, - '\u00BA' => 0xBC, - '\u03A9' => 0xBD, - '\u0103' => 0xBE, - '\u0219' => 0xBF, - '\u00BF' => 0xC0, - '\u00A1' => 0xC1, - '\u00AC' => 0xC2, - '\u221A' => 0xC3, - '\u0192' => 0xC4, - '\u2248' => 0xC5, - '\u2206' => 0xC6, - '\u00AB' => 0xC7, - '\u00BB' => 0xC8, - '\u2026' => 0xC9, - '\u00A0' => 0xCA, - '\u00C0' => 0xCB, - '\u00C3' => 0xCC, - '\u00D5' => 0xCD, - '\u0152' => 0xCE, - '\u0153' => 0xCF, - '\u2013' => 0xD0, - '\u2014' => 0xD1, - '\u201C' => 0xD2, - '\u201D' => 0xD3, - '\u2018' => 0xD4, - '\u2019' => 0xD5, - '\u00F7' => 0xD6, - '\u25CA' => 0xD7, - '\u00FF' => 0xD8, - '\u0178' => 0xD9, - '\u2044' => 0xDA, - '\u20AC' => 0xDB, - '\u2039' => 0xDC, - '\u203A' => 0xDD, - '\u021A' => 0xDE, - '\u021B' => 0xDF, - '\u2021' => 0xE0, - '\u00B7' => 0xE1, - '\u201A' => 0xE2, - '\u201E' => 0xE3, - '\u2030' => 0xE4, - '\u00C2' => 0xE5, - '\u00CA' => 0xE6, - '\u00C1' => 0xE7, - '\u00CB' => 0xE8, - '\u00C8' => 0xE9, - '\u00CD' => 0xEA, - '\u00CE' => 0xEB, - '\u00CF' => 0xEC, - '\u00CC' => 0xED, - '\u00D3' => 0xEE, - '\u00D4' => 0xEF, - '\uF8FF' => 0xF0, - '\u00D2' => 0xF1, - '\u00DA' => 0xF2, - '\u00DB' => 0xF3, - '\u00D9' => 0xF4, - '\u0131' => 0xF5, - '\u02C6' => 0xF6, - '\u02DC' => 0xF7, - '\u00AF' => 0xF8, - '\u02D8' => 0xF9, - '\u02D9' => 0xFA, - '\u02DA' => 0xFB, - '\u00B8' => 0xFC, - '\u02DD' => 0xFD, - '\u02DB' => 0xFE, - '\u02C7' => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an MacRomanian character + /// MacRomanian character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\u0014' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u00C4' => 0x80, + '\u00C5' => 0x81, + '\u00C7' => 0x82, + '\u00C9' => 0x83, + '\u00D1' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u00E1' => 0x87, + '\u00E0' => 0x88, + '\u00E2' => 0x89, + '\u00E4' => 0x8A, + '\u00E3' => 0x8B, + '\u00E5' => 0x8C, + '\u00E7' => 0x8D, + '\u00E9' => 0x8E, + '\u00E8' => 0x8F, + '\u00EA' => 0x90, + '\u00EB' => 0x91, + '\u00ED' => 0x92, + '\u00EC' => 0x93, + '\u00EE' => 0x94, + '\u00EF' => 0x95, + '\u00F1' => 0x96, + '\u00F3' => 0x97, + '\u00F2' => 0x98, + '\u00F4' => 0x99, + '\u00F6' => 0x9A, + '\u00F5' => 0x9B, + '\u00FA' => 0x9C, + '\u00F9' => 0x9D, + '\u00FB' => 0x9E, + '\u00FC' => 0x9F, + '\u2020' => 0xA0, + '\u00B0' => 0xA1, + '\u00A2' => 0xA2, + '\u00A3' => 0xA3, + '\u00A7' => 0xA4, + '\u2022' => 0xA5, + '\u00B6' => 0xA6, + '\u00DF' => 0xA7, + '\u00AE' => 0xA8, + '\u00A9' => 0xA9, + '\u2122' => 0xAA, + '\u00B4' => 0xAB, + '\u00A8' => 0xAC, + '\u2260' => 0xAD, + '\u0102' => 0xAE, + '\u0218' => 0xAF, + '\u221E' => 0xB0, + '\u00B1' => 0xB1, + '\u2264' => 0xB2, + '\u2265' => 0xB3, + '\u00A5' => 0xB4, + '\u00B5' => 0xB5, + '\u2202' => 0xB6, + '\u2211' => 0xB7, + '\u220F' => 0xB8, + '\u03C0' => 0xB9, + '\u222B' => 0xBA, + '\u00AA' => 0xBB, + '\u00BA' => 0xBC, + '\u03A9' => 0xBD, + '\u0103' => 0xBE, + '\u0219' => 0xBF, + '\u00BF' => 0xC0, + '\u00A1' => 0xC1, + '\u00AC' => 0xC2, + '\u221A' => 0xC3, + '\u0192' => 0xC4, + '\u2248' => 0xC5, + '\u2206' => 0xC6, + '\u00AB' => 0xC7, + '\u00BB' => 0xC8, + '\u2026' => 0xC9, + '\u00A0' => 0xCA, + '\u00C0' => 0xCB, + '\u00C3' => 0xCC, + '\u00D5' => 0xCD, + '\u0152' => 0xCE, + '\u0153' => 0xCF, + '\u2013' => 0xD0, + '\u2014' => 0xD1, + '\u201C' => 0xD2, + '\u201D' => 0xD3, + '\u2018' => 0xD4, + '\u2019' => 0xD5, + '\u00F7' => 0xD6, + '\u25CA' => 0xD7, + '\u00FF' => 0xD8, + '\u0178' => 0xD9, + '\u2044' => 0xDA, + '\u20AC' => 0xDB, + '\u2039' => 0xDC, + '\u203A' => 0xDD, + '\u021A' => 0xDE, + '\u021B' => 0xDF, + '\u2021' => 0xE0, + '\u00B7' => 0xE1, + '\u201A' => 0xE2, + '\u201E' => 0xE3, + '\u2030' => 0xE4, + '\u00C2' => 0xE5, + '\u00CA' => 0xE6, + '\u00C1' => 0xE7, + '\u00CB' => 0xE8, + '\u00C8' => 0xE9, + '\u00CD' => 0xEA, + '\u00CE' => 0xEB, + '\u00CF' => 0xEC, + '\u00CC' => 0xED, + '\u00D3' => 0xEE, + '\u00D4' => 0xEF, + '\uF8FF' => 0xF0, + '\u00D2' => 0xF1, + '\u00DA' => 0xF2, + '\u00DB' => 0xF3, + '\u00D9' => 0xF4, + '\u0131' => 0xF5, + '\u02C6' => 0xF6, + '\u02DC' => 0xF7, + '\u00AF' => 0xF8, + '\u02D8' => 0xF9, + '\u02D9' => 0xFA, + '\u02DA' => 0xFB, + '\u00B8' => 0xFC, + '\u02DD' => 0xFD, + '\u02DB' => 0xFE, + '\u02C7' => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacTurkish.cs b/Claunia.Encoding/MacTurkish.cs index 0f2ba05..cc51a51 100644 --- a/Claunia.Encoding/MacTurkish.cs +++ b/Claunia.Encoding/MacTurkish.cs @@ -24,401 +24,400 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Mac Turkish character encoding of Unicode characters. +public class MacTurkish : SingleByteEncoding { - /// Represents an Mac Turkish character encoding of Unicode characters. - public class MacTurkish : SingleByteEncoding + /// + public override string BodyName => "x-mac-turkish"; + /// + public override int CodePage => 10081; + /// + public override string EncodingName => "Turkish (Mac)"; + /// + public override string HeaderName => "x-mac-turkish"; + /// + public override string WebName => "x-mac-turkish"; + /// + public override int WindowsCodePage => 10081; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Macintosh Turkish to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "x-mac-turkish"; - /// - public override int CodePage => 10081; - /// - public override string EncodingName => "Turkish (Mac)"; - /// - public override string HeaderName => "x-mac-turkish"; - /// - public override string WebName => "x-mac-turkish"; - /// - public override int WindowsCodePage => 10081; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Macintosh Turkish to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', - // 0x80 - '\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1', + // 0x90 + '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', - // 0x88 - '\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8', + // 0x98 + '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', - // 0x90 - '\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3', + // 0xA0 + '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', - // 0x98 - '\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', + // 0xA8 + '\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8', - // 0xA0 - '\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF', + // 0xB0 + '\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211', - // 0xA8 - '\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8', + // 0xB8 + '\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8', - // 0xB0 - '\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211', + // 0xC0 + '\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', - // 0xB8 - '\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8', + // 0xC8 + '\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', - // 0xC0 - '\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', + // 0xD0 + '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', - // 0xC8 - '\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', + // 0xD8 + '\u00FF', '\u0178', '\u011E', '\u011F', '\u0130', '\u0131', '\u015E', '\u015F', - // 0xD0 - '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA', + // 0xE0 + '\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1', - // 0xD8 - '\u00FF', '\u0178', '\u011E', '\u011F', '\u0130', '\u0131', '\u015E', '\u015F', + // 0xE8 + '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', - // 0xE0 - '\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1', + // 0xF0 + '\uF8FF', '\u00D2', '\u00DA', '\u00D8', '\u00D9', '\uF8A0', '\u02C6', '\u02DC', - // 0xE8 - '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', + // 0xF8 + '\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7' + }; - // 0xF0 - '\uF8FF', '\u00D2', '\u00DA', '\u00D8', '\u00D9', '\uF8A0', '\u02C6', '\u02DC', - - // 0xF8 - '\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7' - }; - - /// Converts a Unicode character to an Mac Turkish character - /// Mac Turkish character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\u0014' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u00C4' => 0x80, - '\u00C5' => 0x81, - '\u00C7' => 0x82, - '\u00C9' => 0x83, - '\u00D1' => 0x84, - '\u00D6' => 0x85, - '\u00DC' => 0x86, - '\u00E1' => 0x87, - '\u00E0' => 0x88, - '\u00E2' => 0x89, - '\u00E4' => 0x8A, - '\u00E3' => 0x8B, - '\u00E5' => 0x8C, - '\u00E7' => 0x8D, - '\u00E9' => 0x8E, - '\u00E8' => 0x8F, - '\u00EA' => 0x90, - '\u00EB' => 0x91, - '\u00ED' => 0x92, - '\u00EC' => 0x93, - '\u00EE' => 0x94, - '\u00EF' => 0x95, - '\u00F1' => 0x96, - '\u00F3' => 0x97, - '\u00F2' => 0x98, - '\u00F4' => 0x99, - '\u00F6' => 0x9A, - '\u00F5' => 0x9B, - '\u00FA' => 0x9C, - '\u00F9' => 0x9D, - '\u00FB' => 0x9E, - '\u00FC' => 0x9F, - '\u2020' => 0xA0, - '\u00B0' => 0xA1, - '\u00A2' => 0xA2, - '\u00A3' => 0xA3, - '\u00A7' => 0xA4, - '\u2022' => 0xA5, - '\u00B6' => 0xA6, - '\u00DF' => 0xA7, - '\u00AE' => 0xA8, - '\u00A9' => 0xA9, - '\u2122' => 0xAA, - '\u00B4' => 0xAB, - '\u00A8' => 0xAC, - '\u2260' => 0xAD, - '\u00C6' => 0xAE, - '\u00D8' => 0xAF, - '\u221E' => 0xB0, - '\u00B1' => 0xB1, - '\u2264' => 0xB2, - '\u2265' => 0xB3, - '\u00A5' => 0xB4, - '\u00B5' => 0xB5, - '\u2202' => 0xB6, - '\u2211' => 0xB7, - '\u220F' => 0xB8, - '\u03C0' => 0xB9, - '\u222B' => 0xBA, - '\u00AA' => 0xBB, - '\u00BA' => 0xBC, - '\u03A9' => 0xBD, - '\u00E6' => 0xBE, - '\u00F8' => 0xBF, - '\u00BF' => 0xC0, - '\u00A1' => 0xC1, - '\u00AC' => 0xC2, - '\u221A' => 0xC3, - '\u0192' => 0xC4, - '\u2248' => 0xC5, - '\u2206' => 0xC6, - '\u00AB' => 0xC7, - '\u00BB' => 0xC8, - '\u2026' => 0xC9, - '\u00A0' => 0xCA, - '\u00C0' => 0xCB, - '\u00C3' => 0xCC, - '\u00D5' => 0xCD, - '\u0152' => 0xCE, - '\u0153' => 0xCF, - '\u2013' => 0xD0, - '\u2014' => 0xD1, - '\u201C' => 0xD2, - '\u201D' => 0xD3, - '\u2018' => 0xD4, - '\u2019' => 0xD5, - '\u00F7' => 0xD6, - '\u05CA' => 0xD7, - '\u00FF' => 0xD8, - '\u0178' => 0xD9, - '\u011E' => 0xDA, - '\u011F' => 0xDB, - '\u0130' => 0xDC, - '\u0131' => 0xDD, - '\u015E' => 0xDE, - '\u015F' => 0xDF, - '\u2021' => 0xE0, - '\u00B7' => 0xE1, - '\u201A' => 0xE2, - '\u201E' => 0xE3, - '\u2030' => 0xE4, - '\u00C2' => 0xE5, - '\u00CA' => 0xE6, - '\u00C1' => 0xE7, - '\u00CB' => 0xE8, - '\u00C8' => 0xE9, - '\u00CD' => 0xEA, - '\u00CE' => 0xEB, - '\u00CF' => 0xEC, - '\u00CC' => 0xED, - '\u00D3' => 0xEE, - '\u00D4' => 0xEF, - '\uF8FF' => 0xF0, - '\u00D2' => 0xF1, - '\u00DA' => 0xF2, - '\u00DB' => 0xF3, - '\u00D9' => 0xF4, - '\uF8A0' => 0xF5, - '\u02C6' => 0xF6, - '\u02DC' => 0xF7, - '\u00AF' => 0xF8, - '\u02D8' => 0xF9, - '\u02D9' => 0xFA, - '\u02DA' => 0xFB, - '\u00B8' => 0xFC, - '\u02DD' => 0xFD, - '\u02DB' => 0xFE, - '\u02C7' => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Mac Turkish character + /// Mac Turkish character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\u0014' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u00C4' => 0x80, + '\u00C5' => 0x81, + '\u00C7' => 0x82, + '\u00C9' => 0x83, + '\u00D1' => 0x84, + '\u00D6' => 0x85, + '\u00DC' => 0x86, + '\u00E1' => 0x87, + '\u00E0' => 0x88, + '\u00E2' => 0x89, + '\u00E4' => 0x8A, + '\u00E3' => 0x8B, + '\u00E5' => 0x8C, + '\u00E7' => 0x8D, + '\u00E9' => 0x8E, + '\u00E8' => 0x8F, + '\u00EA' => 0x90, + '\u00EB' => 0x91, + '\u00ED' => 0x92, + '\u00EC' => 0x93, + '\u00EE' => 0x94, + '\u00EF' => 0x95, + '\u00F1' => 0x96, + '\u00F3' => 0x97, + '\u00F2' => 0x98, + '\u00F4' => 0x99, + '\u00F6' => 0x9A, + '\u00F5' => 0x9B, + '\u00FA' => 0x9C, + '\u00F9' => 0x9D, + '\u00FB' => 0x9E, + '\u00FC' => 0x9F, + '\u2020' => 0xA0, + '\u00B0' => 0xA1, + '\u00A2' => 0xA2, + '\u00A3' => 0xA3, + '\u00A7' => 0xA4, + '\u2022' => 0xA5, + '\u00B6' => 0xA6, + '\u00DF' => 0xA7, + '\u00AE' => 0xA8, + '\u00A9' => 0xA9, + '\u2122' => 0xAA, + '\u00B4' => 0xAB, + '\u00A8' => 0xAC, + '\u2260' => 0xAD, + '\u00C6' => 0xAE, + '\u00D8' => 0xAF, + '\u221E' => 0xB0, + '\u00B1' => 0xB1, + '\u2264' => 0xB2, + '\u2265' => 0xB3, + '\u00A5' => 0xB4, + '\u00B5' => 0xB5, + '\u2202' => 0xB6, + '\u2211' => 0xB7, + '\u220F' => 0xB8, + '\u03C0' => 0xB9, + '\u222B' => 0xBA, + '\u00AA' => 0xBB, + '\u00BA' => 0xBC, + '\u03A9' => 0xBD, + '\u00E6' => 0xBE, + '\u00F8' => 0xBF, + '\u00BF' => 0xC0, + '\u00A1' => 0xC1, + '\u00AC' => 0xC2, + '\u221A' => 0xC3, + '\u0192' => 0xC4, + '\u2248' => 0xC5, + '\u2206' => 0xC6, + '\u00AB' => 0xC7, + '\u00BB' => 0xC8, + '\u2026' => 0xC9, + '\u00A0' => 0xCA, + '\u00C0' => 0xCB, + '\u00C3' => 0xCC, + '\u00D5' => 0xCD, + '\u0152' => 0xCE, + '\u0153' => 0xCF, + '\u2013' => 0xD0, + '\u2014' => 0xD1, + '\u201C' => 0xD2, + '\u201D' => 0xD3, + '\u2018' => 0xD4, + '\u2019' => 0xD5, + '\u00F7' => 0xD6, + '\u05CA' => 0xD7, + '\u00FF' => 0xD8, + '\u0178' => 0xD9, + '\u011E' => 0xDA, + '\u011F' => 0xDB, + '\u0130' => 0xDC, + '\u0131' => 0xDD, + '\u015E' => 0xDE, + '\u015F' => 0xDF, + '\u2021' => 0xE0, + '\u00B7' => 0xE1, + '\u201A' => 0xE2, + '\u201E' => 0xE3, + '\u2030' => 0xE4, + '\u00C2' => 0xE5, + '\u00CA' => 0xE6, + '\u00C1' => 0xE7, + '\u00CB' => 0xE8, + '\u00C8' => 0xE9, + '\u00CD' => 0xEA, + '\u00CE' => 0xEB, + '\u00CF' => 0xEC, + '\u00CC' => 0xED, + '\u00D3' => 0xEE, + '\u00D4' => 0xEF, + '\uF8FF' => 0xF0, + '\u00D2' => 0xF1, + '\u00DA' => 0xF2, + '\u00DB' => 0xF3, + '\u00D9' => 0xF4, + '\uF8A0' => 0xF5, + '\u02C6' => 0xF6, + '\u02DC' => 0xF7, + '\u00AF' => 0xF8, + '\u02D8' => 0xF9, + '\u02D9' => 0xFA, + '\u02DA' => 0xFB, + '\u00B8' => 0xFC, + '\u02DD' => 0xFD, + '\u02DB' => 0xFE, + '\u02C7' => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/MacUkrainian.cs b/Claunia.Encoding/MacUkrainian.cs index 57df16e..d19121d 100644 --- a/Claunia.Encoding/MacUkrainian.cs +++ b/Claunia.Encoding/MacUkrainian.cs @@ -24,402 +24,401 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Mac Ukrainian character encoding of Unicode characters. +public class MacUkrainian : SingleByteEncoding { - /// Represents an Mac Ukrainian character encoding of Unicode characters. - public class MacUkrainian : SingleByteEncoding + /// + public override string BodyName => "x-mac-ukrainian"; + /// + public override int CodePage => 10017; + /// + public override string EncodingName => "Ukrainian (Mac)"; + /// + public override string HeaderName => "x-mac-ukrainian"; + /// + public override string WebName => "x-mac-ukrainian"; + /// + public override int WindowsCodePage => 10017; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => true; + /// + public override bool IsSingleByte => true; + + /// The Macintosh Ukrainian to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "x-mac-ukrainian"; - /// - public override int CodePage => 10017; - /// - public override string EncodingName => "Ukrainian (Mac)"; - /// - public override string HeaderName => "x-mac-ukrainian"; - /// - public override string WebName => "x-mac-ukrainian"; - /// - public override int WindowsCodePage => 10017; + // 0x00 + '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => true; - /// - public override bool IsSingleByte => true; + // 0x08 + '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - /// The Macintosh Ukrainian to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', + // 0x10 + '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', - // 0x08 - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', + // 0x18 + '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - // 0x10 - '\u0010', '\u2318', '\u2713', '\u25C6', '\uF8FF', '\u0015', '\u0016', '\u0017', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416', '\u0417', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F', + // 0x88 + '\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D', '\u041E', '\u041F', - // 0x80 - '\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416', '\u0417', + // 0x90 + '\u0420', '\u0421', '\u0422', '\u0423', '\u0424', '\u0425', '\u0426', '\u0427', - // 0x88 - '\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D', '\u041E', '\u041F', + // 0x98 + '\u0428', '\u0429', '\u042A', '\u042B', '\u042C', '\u042D', '\u042E', '\u042F', - // 0x90 - '\u0420', '\u0421', '\u0422', '\u0423', '\u0424', '\u0425', '\u0426', '\u0427', + // 0xA0 + '\u2020', '\u00B0', '\u0490', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u0406', - // 0x98 - '\u0428', '\u0429', '\u042A', '\u042B', '\u042C', '\u042D', '\u042E', '\u042F', + // 0xA8 + '\u00AE', '\u00A9', '\u2122', '\u0402', '\u0452', '\u2260', '\u0403', '\u0453', - // 0xA0 - '\u2020', '\u00B0', '\u0490', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u0406', + // 0xB0 + '\u221E', '\u00B1', '\u2264', '\u2265', '\u0456', '\u00B5', '\u0491', '\u0408', - // 0xA8 - '\u00AE', '\u00A9', '\u2122', '\u0402', '\u0452', '\u2260', '\u0403', '\u0453', + // 0xB8 + '\u0404', '\u0454', '\u0407', '\u0457', '\u0409', '\u0459', '\u040A', '\u045A', - // 0xB0 - '\u221E', '\u00B1', '\u2264', '\u2265', '\u0456', '\u00B5', '\u0491', '\u0408', + // 0xC0 + '\u0458', '\u0405', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', - // 0xB8 - '\u0404', '\u0454', '\u0407', '\u0457', '\u0409', '\u0459', '\u040A', '\u045A', + // 0xC8 + '\u00BB', '\u2026', '\u00A0', '\u040B', '\u045B', '\u040C', '\u045C', '\u0455', - // 0xC0 - '\u0458', '\u0405', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB', + // 0xD0 + '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u201E', - // 0xC8 - '\u00BB', '\u2026', '\u00A0', '\u040B', '\u045B', '\u040C', '\u045C', '\u0455', + // 0xD8 + '\u040E', '\u045E', '\u040F', '\u045F', '\u2116', '\u0401', '\u0451', '\u044F', - // 0xD0 - '\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u201E', + // 0xE0 + '\u0430', '\u0431', '\u0432', '\u0433', '\u0434', '\u0435', '\u0436', '\u0437', - // 0xD8 - '\u040E', '\u045E', '\u040F', '\u045F', '\u2116', '\u0401', '\u0451', '\u044F', + // 0xE8 + '\u0438', '\u0439', '\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F', - // 0xE0 - '\u0430', '\u0431', '\u0432', '\u0433', '\u0434', '\u0435', '\u0436', '\u0437', + // 0xF0 + '\u0440', '\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447', - // 0xE8 - '\u0438', '\u0439', '\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F', + // 0xF8 + '\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E', '\u20AC' + }; - // 0xF0 - '\u0440', '\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447', - - // 0xF8 - '\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E', '\u20AC' - }; - - /// Converts a Unicode character to an Mac Ukrainian character - /// Mac Ukrainian character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0000' => 0x00, - '\u0001' => 0x01, - '\u0002' => 0x02, - '\u0003' => 0x03, - '\u0004' => 0x04, - '\u0005' => 0x05, - '\u0006' => 0x06, - '\u0007' => 0x07, - '\u0008' => 0x08, - '\u0009' => 0x09, - '\u000A' => 0x0A, - '\u000B' => 0x0B, - '\u000C' => 0x0C, - '\u000D' => 0x0D, - '\u000E' => 0x0E, - '\u000F' => 0x0F, - '\u0010' => 0x10, - '\u2318' => 0x11, - '\u0012' => 0x12, - '\u2713' => 0x12, - '\u0013' => 0x13, - '\u25C6' => 0x13, - '\uF8FF' => 0x13, - '\u0014' => 0x14, - '\u0015' => 0x15, - '\u0016' => 0x16, - '\u0017' => 0x17, - '\u0018' => 0x18, - '\u0019' => 0x19, - '\u001A' => 0x1A, - '\u001B' => 0x1B, - '\u001C' => 0x1C, - '\u001D' => 0x1D, - '\u001E' => 0x1E, - '\u001F' => 0x1F, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u005E' => 0x5E, - '\u005F' => 0x5F, - '\u0060' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u007F' => 0x7F, - '\u0410' => 0x80, - '\u0411' => 0x81, - '\u0412' => 0x82, - '\u0413' => 0x83, - '\u0414' => 0x84, - '\u0415' => 0x85, - '\u0416' => 0x86, - '\u0417' => 0x87, - '\u0418' => 0x88, - '\u0419' => 0x89, - '\u041A' => 0x8A, - '\u041B' => 0x8B, - '\u041C' => 0x8C, - '\u041D' => 0x8D, - '\u041E' => 0x8E, - '\u041F' => 0x8F, - '\u0420' => 0x90, - '\u0421' => 0x91, - '\u0422' => 0x92, - '\u0423' => 0x93, - '\u0424' => 0x94, - '\u0425' => 0x95, - '\u0426' => 0x96, - '\u0427' => 0x97, - '\u0428' => 0x98, - '\u0429' => 0x99, - '\u042A' => 0x9A, - '\u042B' => 0x9B, - '\u042C' => 0x9C, - '\u042D' => 0x9D, - '\u042E' => 0x9E, - '\u042F' => 0x9F, - '\u2020' => 0xA0, - '\u00B0' => 0xA1, - '\u0490' => 0xA2, - '\u00A3' => 0xA3, - '\u00A7' => 0xA4, - '\u2022' => 0xA5, - '\u00B6' => 0xA6, - '\u0406' => 0xA7, - '\u00AE' => 0xA8, - '\u00A9' => 0xA9, - '\u2122' => 0xAA, - '\u0402' => 0xAB, - '\u0452' => 0xAC, - '\u2260' => 0xAD, - '\u0403' => 0xAE, - '\u0453' => 0xAF, - '\u221E' => 0xB0, - '\u00B1' => 0xB1, - '\u2264' => 0xB2, - '\u2265' => 0xB3, - '\u0456' => 0xB4, - '\u00B5' => 0xB5, - '\u0491' => 0xB6, - '\u0408' => 0xB7, - '\u0404' => 0xB8, - '\u0454' => 0xB9, - '\u0407' => 0xBA, - '\u0457' => 0xBB, - '\u0409' => 0xBC, - '\u0459' => 0xBD, - '\u040A' => 0xBE, - '\u045A' => 0xBF, - '\u0458' => 0xC0, - '\u0405' => 0xC1, - '\u00AC' => 0xC2, - '\u221A' => 0xC3, - '\u0192' => 0xC4, - '\u2248' => 0xC5, - '\u2206' => 0xC6, - '\u00AB' => 0xC7, - '\u00BB' => 0xC8, - '\u2026' => 0xC9, - '\u00A0' => 0xCA, - '\u040B' => 0xCB, - '\u045B' => 0xCC, - '\u040C' => 0xCD, - '\u045C' => 0xCE, - '\u0455' => 0xCF, - '\u2013' => 0xD0, - '\u2014' => 0xD1, - '\u201C' => 0xD2, - '\u201D' => 0xD3, - '\u2018' => 0xD4, - '\u2019' => 0xD5, - '\u00F7' => 0xD6, - '\u201E' => 0xD7, - '\u040E' => 0xD8, - '\u045E' => 0xD9, - '\u040F' => 0xDA, - '\u045F' => 0xDB, - '\u2116' => 0xDC, - '\u0401' => 0xDD, - '\u0451' => 0xDE, - '\u044F' => 0xDF, - '\u0430' => 0xE0, - '\u0431' => 0xE1, - '\u0432' => 0xE2, - '\u0433' => 0xE3, - '\u0434' => 0xE4, - '\u0435' => 0xE5, - '\u0436' => 0xE6, - '\u0437' => 0xE7, - '\u0438' => 0xE8, - '\u0439' => 0xE9, - '\u043A' => 0xEA, - '\u043B' => 0xEB, - '\u043C' => 0xEC, - '\u043D' => 0xED, - '\u043E' => 0xEE, - '\u043F' => 0xEF, - '\u0440' => 0xF0, - '\u0441' => 0xF1, - '\u0442' => 0xF2, - '\u0443' => 0xF3, - '\u0444' => 0xF4, - '\u0445' => 0xF5, - '\u0446' => 0xF6, - '\u0447' => 0xF7, - '\u0448' => 0xF8, - '\u0449' => 0xF9, - '\u044A' => 0xFA, - '\u044B' => 0xFB, - '\u044C' => 0xFC, - '\u044D' => 0xFD, - '\u044E' => 0xFE, - '\u20AC' => 0xFF, - _ => 0x3F - }; - } + /// Converts a Unicode character to an Mac Ukrainian character + /// Mac Ukrainian character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0000' => 0x00, + '\u0001' => 0x01, + '\u0002' => 0x02, + '\u0003' => 0x03, + '\u0004' => 0x04, + '\u0005' => 0x05, + '\u0006' => 0x06, + '\u0007' => 0x07, + '\u0008' => 0x08, + '\u0009' => 0x09, + '\u000A' => 0x0A, + '\u000B' => 0x0B, + '\u000C' => 0x0C, + '\u000D' => 0x0D, + '\u000E' => 0x0E, + '\u000F' => 0x0F, + '\u0010' => 0x10, + '\u2318' => 0x11, + '\u0012' => 0x12, + '\u2713' => 0x12, + '\u0013' => 0x13, + '\u25C6' => 0x13, + '\uF8FF' => 0x13, + '\u0014' => 0x14, + '\u0015' => 0x15, + '\u0016' => 0x16, + '\u0017' => 0x17, + '\u0018' => 0x18, + '\u0019' => 0x19, + '\u001A' => 0x1A, + '\u001B' => 0x1B, + '\u001C' => 0x1C, + '\u001D' => 0x1D, + '\u001E' => 0x1E, + '\u001F' => 0x1F, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u005E' => 0x5E, + '\u005F' => 0x5F, + '\u0060' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u007F' => 0x7F, + '\u0410' => 0x80, + '\u0411' => 0x81, + '\u0412' => 0x82, + '\u0413' => 0x83, + '\u0414' => 0x84, + '\u0415' => 0x85, + '\u0416' => 0x86, + '\u0417' => 0x87, + '\u0418' => 0x88, + '\u0419' => 0x89, + '\u041A' => 0x8A, + '\u041B' => 0x8B, + '\u041C' => 0x8C, + '\u041D' => 0x8D, + '\u041E' => 0x8E, + '\u041F' => 0x8F, + '\u0420' => 0x90, + '\u0421' => 0x91, + '\u0422' => 0x92, + '\u0423' => 0x93, + '\u0424' => 0x94, + '\u0425' => 0x95, + '\u0426' => 0x96, + '\u0427' => 0x97, + '\u0428' => 0x98, + '\u0429' => 0x99, + '\u042A' => 0x9A, + '\u042B' => 0x9B, + '\u042C' => 0x9C, + '\u042D' => 0x9D, + '\u042E' => 0x9E, + '\u042F' => 0x9F, + '\u2020' => 0xA0, + '\u00B0' => 0xA1, + '\u0490' => 0xA2, + '\u00A3' => 0xA3, + '\u00A7' => 0xA4, + '\u2022' => 0xA5, + '\u00B6' => 0xA6, + '\u0406' => 0xA7, + '\u00AE' => 0xA8, + '\u00A9' => 0xA9, + '\u2122' => 0xAA, + '\u0402' => 0xAB, + '\u0452' => 0xAC, + '\u2260' => 0xAD, + '\u0403' => 0xAE, + '\u0453' => 0xAF, + '\u221E' => 0xB0, + '\u00B1' => 0xB1, + '\u2264' => 0xB2, + '\u2265' => 0xB3, + '\u0456' => 0xB4, + '\u00B5' => 0xB5, + '\u0491' => 0xB6, + '\u0408' => 0xB7, + '\u0404' => 0xB8, + '\u0454' => 0xB9, + '\u0407' => 0xBA, + '\u0457' => 0xBB, + '\u0409' => 0xBC, + '\u0459' => 0xBD, + '\u040A' => 0xBE, + '\u045A' => 0xBF, + '\u0458' => 0xC0, + '\u0405' => 0xC1, + '\u00AC' => 0xC2, + '\u221A' => 0xC3, + '\u0192' => 0xC4, + '\u2248' => 0xC5, + '\u2206' => 0xC6, + '\u00AB' => 0xC7, + '\u00BB' => 0xC8, + '\u2026' => 0xC9, + '\u00A0' => 0xCA, + '\u040B' => 0xCB, + '\u045B' => 0xCC, + '\u040C' => 0xCD, + '\u045C' => 0xCE, + '\u0455' => 0xCF, + '\u2013' => 0xD0, + '\u2014' => 0xD1, + '\u201C' => 0xD2, + '\u201D' => 0xD3, + '\u2018' => 0xD4, + '\u2019' => 0xD5, + '\u00F7' => 0xD6, + '\u201E' => 0xD7, + '\u040E' => 0xD8, + '\u045E' => 0xD9, + '\u040F' => 0xDA, + '\u045F' => 0xDB, + '\u2116' => 0xDC, + '\u0401' => 0xDD, + '\u0451' => 0xDE, + '\u044F' => 0xDF, + '\u0430' => 0xE0, + '\u0431' => 0xE1, + '\u0432' => 0xE2, + '\u0433' => 0xE3, + '\u0434' => 0xE4, + '\u0435' => 0xE5, + '\u0436' => 0xE6, + '\u0437' => 0xE7, + '\u0438' => 0xE8, + '\u0439' => 0xE9, + '\u043A' => 0xEA, + '\u043B' => 0xEB, + '\u043C' => 0xEC, + '\u043D' => 0xED, + '\u043E' => 0xEE, + '\u043F' => 0xEF, + '\u0440' => 0xF0, + '\u0441' => 0xF1, + '\u0442' => 0xF2, + '\u0443' => 0xF3, + '\u0444' => 0xF4, + '\u0445' => 0xF5, + '\u0446' => 0xF6, + '\u0447' => 0xF7, + '\u0448' => 0xF8, + '\u0449' => 0xF9, + '\u044A' => 0xFA, + '\u044B' => 0xFB, + '\u044C' => 0xFC, + '\u044D' => 0xFD, + '\u044E' => 0xFE, + '\u20AC' => 0xFF, + _ => 0x3F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/PETSCII.cs b/Claunia.Encoding/PETSCII.cs index ad933e5..a7165f6 100644 --- a/Claunia.Encoding/PETSCII.cs +++ b/Claunia.Encoding/PETSCII.cs @@ -26,189 +26,188 @@ using System.Text; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// +/// Represents an Commodore PET Standard Code for Information Interchange (aka CBM ASCII) character encoding of +/// Unicode characters. +/// +public class PETSCII : SingleByteEncodingWithRunes { - /// - /// Represents an Commodore PET Standard Code for Information Interchange (aka CBM ASCII) character encoding of - /// Unicode characters. - /// - public class PETSCII : SingleByteEncodingWithRunes + /// + public override string BodyName => "petscii"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Commodore PET Standard Code for Information Interchange"; + /// + public override string HeaderName => "petscii"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => true; + + /// The PETSCII to Unicode character map, unshifted (default) variant. + /// Reference used: http://style64.org/petscii/ and others. + protected override Rune[] CharTable => new[] { - /// - public override string BodyName => "petscii"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Commodore PET Standard Code for Information Interchange"; - /// - public override string HeaderName => "petscii"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0003), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => true; + // 0x08 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x000A), + new Rune(0x0000), new Rune(0x0000), - /// The PETSCII to Unicode character map, unshifted (default) variant. - /// Reference used: http://style64.org/petscii/ and others. - protected override Rune[] CharTable => new[] - { - // 0x00 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0003), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x10 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0008), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x08 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x000A), - new Rune(0x0000), new Rune(0x0000), + // 0x18 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x10 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0008), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x20 + new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), + new Rune(0x0026), new Rune(0x0027), - // 0x18 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x28 + new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), + new Rune(0x002E), new Rune(0x002F), - // 0x20 - new Rune(0x0020), new Rune(0x0021), new Rune(0x0022), new Rune(0x0023), new Rune(0x0024), new Rune(0x0025), - new Rune(0x0026), new Rune(0x0027), + // 0x30 + new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), + new Rune(0x0036), new Rune(0x0037), - // 0x28 - new Rune(0x0028), new Rune(0x0029), new Rune(0x002A), new Rune(0x002B), new Rune(0x002C), new Rune(0x002D), - new Rune(0x002E), new Rune(0x002F), + // 0x38 + new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), + new Rune(0x003E), new Rune(0x003F), - // 0x30 - new Rune(0x0030), new Rune(0x0031), new Rune(0x0032), new Rune(0x0033), new Rune(0x0034), new Rune(0x0035), - new Rune(0x0036), new Rune(0x0037), + // 0x40 + new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), + new Rune(0x0046), new Rune(0x0047), - // 0x38 - new Rune(0x0038), new Rune(0x0039), new Rune(0x003A), new Rune(0x003B), new Rune(0x003C), new Rune(0x003D), - new Rune(0x003E), new Rune(0x003F), + // 0x48 + new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), + new Rune(0x004E), new Rune(0x004F), - // 0x40 - new Rune(0x0040), new Rune(0x0041), new Rune(0x0042), new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), - new Rune(0x0046), new Rune(0x0047), + // 0x50 + new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), + new Rune(0x0056), new Rune(0x0057), - // 0x48 - new Rune(0x0048), new Rune(0x0049), new Rune(0x004A), new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), - new Rune(0x004E), new Rune(0x004F), + // 0x58 + new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x00A3), new Rune(0x005D), + new Rune(0x2191), new Rune(0x2190), - // 0x50 - new Rune(0x0050), new Rune(0x0051), new Rune(0x0052), new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), - new Rune(0x0056), new Rune(0x0057), + // 0x60 + new Rune(0x1FB79), new Rune(0x2660), new Rune(0x1FB72), new Rune(0x1FB78), new Rune(0x1FB77), + new Rune(0x1FB76), new Rune(0x1FB7A), new Rune(0x1FB71), - // 0x58 - new Rune(0x0058), new Rune(0x0059), new Rune(0x005A), new Rune(0x005B), new Rune(0x00A3), new Rune(0x005D), - new Rune(0x2191), new Rune(0x2190), + // 0x68 + new Rune(0x1FB74), new Rune(0x256E), new Rune(0x2570), new Rune(0x256F), new Rune(0x1FB7C), + new Rune(0x2572), new Rune(0x2571), new Rune(0x1FB7D), - // 0x60 - new Rune(0x1FB79), new Rune(0x2660), new Rune(0x1FB72), new Rune(0x1FB78), new Rune(0x1FB77), - new Rune(0x1FB76), new Rune(0x1FB7A), new Rune(0x1FB71), + // 0x70 + new Rune(0x1FB7E), new Rune(0x25CF), new Rune(0x1FB7B), new Rune(0x2665), new Rune(0x1FB70), + new Rune(0x256D), new Rune(0x2573), new Rune(0x25CB), - // 0x68 - new Rune(0x1FB74), new Rune(0x256E), new Rune(0x2570), new Rune(0x256F), new Rune(0x1FB7C), - new Rune(0x2572), new Rune(0x2571), new Rune(0x1FB7D), + // 0x78 + new Rune(0x2663), new Rune(0x1FB75), new Rune(0x2666), new Rune(0x253C), new Rune(0x1FB8C), + new Rune(0x2502), new Rune(0x03C0), new Rune(0x25E5), - // 0x70 - new Rune(0x1FB7E), new Rune(0x25CF), new Rune(0x1FB7B), new Rune(0x2665), new Rune(0x1FB70), - new Rune(0x256D), new Rune(0x2573), new Rune(0x25CB), + // 0x80 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x78 - new Rune(0x2663), new Rune(0x1FB75), new Rune(0x2666), new Rune(0x253C), new Rune(0x1FB8C), - new Rune(0x2502), new Rune(0x03C0), new Rune(0x25E5), + // 0x88 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x2028), + new Rune(0x0000), new Rune(0x0000), - // 0x80 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x90 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x88 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x2028), - new Rune(0x0000), new Rune(0x0000), + // 0x98 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x90 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xA0 + new Rune(0x00A0), new Rune(0x258C), new Rune(0x2584), new Rune(0x2594), new Rune(0x2581), new Rune(0x258E), + new Rune(0x2592), new Rune(0x2595), - // 0x98 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xA8 + new Rune(0x1FB8F), new Rune(0x25E4), new Rune(0x1FB87), new Rune(0x251C), new Rune(0x2597), + new Rune(0x2514), new Rune(0x2510), new Rune(0x2582), - // 0xA0 - new Rune(0x00A0), new Rune(0x258C), new Rune(0x2584), new Rune(0x2594), new Rune(0x2581), new Rune(0x258E), - new Rune(0x2592), new Rune(0x2595), + // 0xB0 + new Rune(0x250C), new Rune(0x2534), new Rune(0x252C), new Rune(0x2524), new Rune(0x258E), new Rune(0x258D), + new Rune(0x1FB88), new Rune(0x1FB82), - // 0xA8 - new Rune(0x1FB8F), new Rune(0x25E4), new Rune(0x1FB87), new Rune(0x251C), new Rune(0x2597), - new Rune(0x2514), new Rune(0x2510), new Rune(0x2582), + // 0xB8 + new Rune(0x1FB83), new Rune(0x2583), new Rune(0x1FB7F), new Rune(0x2596), new Rune(0x259D), + new Rune(0x2518), new Rune(0x2598), new Rune(0x259A), - // 0xB0 - new Rune(0x250C), new Rune(0x2534), new Rune(0x252C), new Rune(0x2524), new Rune(0x258E), new Rune(0x258D), - new Rune(0x1FB88), new Rune(0x1FB82), + // 0xC0 (repeats 0x60 - 0x67) + new Rune(0x1FB79), new Rune(0x2660), new Rune(0x1FB72), new Rune(0x1FB78), new Rune(0x1FB77), + new Rune(0x1FB76), new Rune(0x1FB7A), new Rune(0x1FB71), - // 0xB8 - new Rune(0x1FB83), new Rune(0x2583), new Rune(0x1FB7F), new Rune(0x2596), new Rune(0x259D), - new Rune(0x2518), new Rune(0x2598), new Rune(0x259A), + // 0xC8 (repeats 0x68 - 0x6F) + new Rune(0x1FB74), new Rune(0x256E), new Rune(0x2570), new Rune(0x256F), new Rune(0x1FB7C), + new Rune(0x2572), new Rune(0x2571), new Rune(0x1FB7D), - // 0xC0 (repeats 0x60 - 0x67) - new Rune(0x1FB79), new Rune(0x2660), new Rune(0x1FB72), new Rune(0x1FB78), new Rune(0x1FB77), - new Rune(0x1FB76), new Rune(0x1FB7A), new Rune(0x1FB71), + // 0xD0 (repeats 0x70 - 0x77) + new Rune(0x1FB7E), new Rune(0x25CF), new Rune(0x1FB7B), new Rune(0x2665), new Rune(0x1FB70), + new Rune(0x256D), new Rune(0x2573), new Rune(0x25CB), - // 0xC8 (repeats 0x68 - 0x6F) - new Rune(0x1FB74), new Rune(0x256E), new Rune(0x2570), new Rune(0x256F), new Rune(0x1FB7C), - new Rune(0x2572), new Rune(0x2571), new Rune(0x1FB7D), + // 0xD8 (repeats 0x78 - 0x7F) + new Rune(0x2663), new Rune(0x1FB75), new Rune(0x2666), new Rune(0x253C), new Rune(0x1FB8C), + new Rune(0x2502), new Rune(0x03C0), new Rune(0x25E5), - // 0xD0 (repeats 0x70 - 0x77) - new Rune(0x1FB7E), new Rune(0x25CF), new Rune(0x1FB7B), new Rune(0x2665), new Rune(0x1FB70), - new Rune(0x256D), new Rune(0x2573), new Rune(0x25CB), + // 0xE0 (repeats 0xA0 - 0xA7) + new Rune(0x00A0), new Rune(0x258C), new Rune(0x2584), new Rune(0x2594), new Rune(0x2581), new Rune(0x258E), + new Rune(0x2592), new Rune(0x2595), - // 0xD8 (repeats 0x78 - 0x7F) - new Rune(0x2663), new Rune(0x1FB75), new Rune(0x2666), new Rune(0x253C), new Rune(0x1FB8C), - new Rune(0x2502), new Rune(0x03C0), new Rune(0x25E5), + // 0xE8 (repeats 0xA8 - 0xAF) + new Rune(0x1FB8F), new Rune(0x25E4), new Rune(0x1FB87), new Rune(0x251C), new Rune(0x2597), + new Rune(0x2514), new Rune(0x2510), new Rune(0x2582), - // 0xE0 (repeats 0xA0 - 0xA7) - new Rune(0x00A0), new Rune(0x258C), new Rune(0x2584), new Rune(0x2594), new Rune(0x2581), new Rune(0x258E), - new Rune(0x2592), new Rune(0x2595), + // 0xF0 (repeats 0xB0 - 0xB7) + new Rune(0x250C), new Rune(0x2534), new Rune(0x252C), new Rune(0x2524), new Rune(0x258E), new Rune(0x258D), + new Rune(0x1FB88), new Rune(0x1FB82), - // 0xE8 (repeats 0xA8 - 0xAF) - new Rune(0x1FB8F), new Rune(0x25E4), new Rune(0x1FB87), new Rune(0x251C), new Rune(0x2597), - new Rune(0x2514), new Rune(0x2510), new Rune(0x2582), + // 0xF8 (repeats 0xB8 - 0xBF) + new Rune(0x1FB83), new Rune(0x2583), new Rune(0x1FB7F), new Rune(0x2596), new Rune(0x259D), + new Rune(0x2518), new Rune(0x2598), new Rune(0x259A) + }; - // 0xF0 (repeats 0xB0 - 0xB7) - new Rune(0x250C), new Rune(0x2534), new Rune(0x252C), new Rune(0x2524), new Rune(0x258E), new Rune(0x258D), - new Rune(0x1FB88), new Rune(0x1FB82), - - // 0xF8 (repeats 0xB8 - 0xBF) - new Rune(0x1FB83), new Rune(0x2583), new Rune(0x1FB7F), new Rune(0x2596), new Rune(0x259D), - new Rune(0x2518), new Rune(0x2598), new Rune(0x259A) - }; - - /// Converts a Unicode character to an PETSCII character - /// PETSCII character. - /// Unicode character. - private protected override byte GetByte(Rune character) - { - if(character.Value == 0x0000) - return 0x3F; - - for(int i = 0; i < 256; i++) - - // TODO: convert this to a gigantic switch statement too? - if(CharTable[i] == character) - return (byte)i; - - // Fallback to '?' + /// Converts a Unicode character to an PETSCII character + /// PETSCII character. + /// Unicode character. + private protected override byte GetByte(Rune character) + { + if(character.Value == 0x0000) return 0x3F; - } + + for(int i = 0; i < 256; i++) + + // TODO: convert this to a gigantic switch statement too? + if(CharTable[i] == character) + return (byte)i; + + // Fallback to '?' + return 0x3F; } } \ No newline at end of file diff --git a/Claunia.Encoding/Pangrams.cs b/Claunia.Encoding/Pangrams.cs index 65327ce..847e24a 100644 --- a/Claunia.Encoding/Pangrams.cs +++ b/Claunia.Encoding/Pangrams.cs @@ -24,110 +24,109 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Class containing pangrams for several languages that can be used to test encoding. +public static class Pangrams { - /// Class containing pangrams for several languages that can be used to test encoding. - public static class Pangrams - { - /// A pangram that contains all (or most) Arabic characters. - public const string ARABIC = - "صِف خَلقَ خَودِ كَمِثلِ الشَمسِ إِذ بَزَغَت — يَحظى الضَجيعُ بِها نَجلاءَ مِعطارِ"; - /// A pangram that contains all (or most) Azeri characters. - public const string AZERI = "Zəfər, jaketini də papağını da götür, bu axşam hava çox soyuq olacaq."; - /// A pangram that contains all (or most) Basque characters. - public const string BASQUE = "Vaudeville itxurako filmean, yogi ñaño bat jipoitzen dute Quebec-en, whiski truk"; - /// A pangram that contains all (or most) Breton characters. - public const string BRETON = - "Yec’hed mat Jakez ! Skarzhit ar gwerennoù-mañ, kavet e vo gwin betek fin ho puhez."; - /// A pangram that contains all (or most) Bulgarian characters. - public const string BULGARIAN = "Хълцащ змей плюе шофьор стигнал чуждия бивак."; - /// A pangram that contains all (or most) Catalan characters. - public const string CATALAN = - "«Dóna amor que seràs feliç!». Això, il·lús company geniüt, ja és un lluït rètol blavís d’onze kWh."; - /// A pangram that contains Traditional Chinese characters. - public const string CHINESE_TRADITIONAL = "視野無限廣,窗外有藍天"; - /// A pangram that contains Simplified Chinese characters. - public const string CHINESE_SIMPLIFIED = "Innovation in China 中国智造,慧及全球"; - /// A pangram that contains all (or most) Croatian characters. - public const string CROATIAN = "Gojazni đačić s biciklom drži hmelj i finu vatu u džepu nošnje."; - /// A pangram that contains all (or most) Czech characters. - public const string CZECH = - "Nechť již hříšné saxofony ďáblů rozezvučí síň úděsnými tóny waltzu, tanga a quickstepu."; - /// A pangram that contains all (or most) Danish characters. - public const string DANISH = - "Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Walther spillede på xylofon."; - /// A pangram that contains all (or most) Dutch characters. - public const string DUTCH = "Pa’s wijze lynx bezag vroom het fikse aquaduct."; - /// A pangram that contains all (or most) English characters. - public const string ENGLISH = "The quick brown fox jumps over the lazy dog."; - /// A pangram that contains all (or most) Esperanto characters. - public const string ESPERANTO = "Eble ĉiu kvazaŭ-deca fuŝĥoraĵo ĝojigos homtipon."; - /// A pangram that contains all (or most) Estonian characters. - public const string ESTONIAN = "Põdur Zagrebi tšellomängija-följetonist Ciqo külmetas kehvas garaažis."; - /// A pangram that contains all (or most) Finnish characters. - public const string FINNISH = - "Fahrenheit ja Celsius yrjösivät Åsan backgammon-peliin, Volkswagenissa, daiquirin ja ZX81:n yhteisvaikutuksesta."; - /// A pangram that contains all (or most) French characters. - public const string FRENCH = - "Le cœur déçu mais l'âme plutôt naïve, Louÿs rêva de crapaüter en canoë au delà des îles, près du mälströn où brûlent les novæ."; - /// A pangram that contains all (or most) Galician characters. - public const string GALICIAN = - "Necesitamos unha tipografía chuliña de cor kiwi, que lle zorregue unha labazada visual á xente."; - /// A pangram that contains all (or most) German characters. - public const string GERMAN = "Falsches Üben von Xylophonmusik quält jeden größeren Zwerg."; - /// A pangram that contains all (or most) Greek characters. - public const string GREEK = - "Ταχίστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός Takhístè alôpèx vaphês psèménè gè, draskelízei ypér nòthroý kynós."; - /// A pangram that contains all (or most) Hebrew characters. - public const string HEBREW = - "לכן חכו לי נאם יהוה ליום קומי לעד, כי משפטי לאסף גוים לקבצי ממלכות, לשפך עליהם זעמי כל חרון אפי, כי באש קנאתי תאכל כל הארץ"; - /// A pangram that contains all (or most) Hungarian characters. - public const string HUNGARIAN = "Jó foxim és don Quijote húszwattos lámpánál ülve egy pár bűvös cipőt készít."; - /// A pangram that contains all (or most) Icelandic characters. - public const string ICELANDIC = "Kæmi ný öxi hér, ykist þjófum nú bæði víl og ádrepa."; - /// A pangram that contains all (or most) Irish Gaelic characters. - public const string IRISH = "Ċuaiġ bé ṁórṡáċ le dlúṫspád fíorḟinn trí hata mo ḋea-ṗorcáin ḃig"; - /// A pangram that contains all (or most) Japanese kanas. - public const string JAPANESE = "いろはにほへと ちりぬるを わかよたれそ つねならむ うゐのおくやま けふこえて あさきゆめみし ゑひもせす(ん)"; - /// using Kanjis - public const string JAPANESE_KANJI = "色は匂へど 散りぬるを 我が世誰ぞ 常ならむ 有為の奥山 今日越えて 浅き夢見じ 酔ひもせず(ん)"; - /// A pangram that contains all (or most) Korean characters. - public const string KOREAN = "키스의 고유조건은 입술끼리 만나야 하고 특별한 기술은 필요치 않다"; - /// A pangram that contains all (or most) Latvian characters. - public const string LATVIAN = "Četri psihi faķīri vēlu vakarā zāģēja guļbūvei durvis, fonā šņācot mežam."; - /// A pangram that contains all (or most) Lithuanian characters. - public const string LITHUANIAN = "Įlinkdama fechtuotojo špaga sublykčiojusi pragręžė apvalų arbūzą"; - /// A pangram that contains all (or most) Macedonian characters. - public const string MACEDONIAN = "Ѕидарски пејзаж: шугав билмез со чудење џвака ќофте и кељ на туѓ цех."; - /// A pangram that contains all (or most) Norwegian characters. - public const string NORWEGIAN = "Jeg begynte å fortære en sandwich mens jeg kjørte taxi på vei til quiz"; - /// A pangram that contains all (or most) Polish characters. - public const string POLISH = "Jeżu klątw, spłódź Finom część gry hańb!"; - /// A pangram that contains all (or most) Portuguese characters. - public const string PORTUGUESE = - "À noite, vovô Kowalsky vê o ímã cair no pé do pingüim queixoso e vovó põe açúcar no chá de tâmaras do jabuti feliz."; - /// A pangram that contains all (or most) Romanian characters. - public const string ROMANIAN = "Înjurând pițigăiat, zoofobul comandă vexat whisky și tequila."; - /// A pangram that contains all (or most) Russian characters. - public const string RUSSIAN = - "Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства."; - /// A pangram that contains all (or most) Scottish Gaelic characters. - public const string SCOTTISH = "Mus d’fhàg Cèit-Ùna ròp Ì le ob."; - /// A pangram that contains all (or most) Serbian characters. - public const string SERBIAN = "Gojazni đačić s biciklom drži hmelj i finu vatu u džepu nošnje."; - /// A pangram that contains all (or most) Slovak characters. - public const string SLOVAK = - "Kŕdeľ šťastných ďatľov učí pri ústí Váhu mĺkveho koňa obhrýzať kôru a žrať čerstvé mäso."; - /// A pangram that contains all (or most) Slovenian characters. - public const string SLOVENIAN = "Besni dirkač iz formule žuga cehu poštarjev."; - /// A pangram that contains all (or most) Spanish characters. - public const string SPANISH = - "El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja."; - /// A pangram that contains all (or most) Swedish characters. - public const string SWEDISH = "Flygande bäckasiner söka hwila på mjuka tuvor."; - /// A pangram that contains all (or most) Turkish characters. - public const string TURKISH = "Pijamalı hasta yağız şoföre çabucak güvendi."; - /// A pangram that contains all (or most) Welsh characters. - public const string WELSH = "Parciais fy jac codi baw hud llawn dŵr ger tŷ Mabon."; - } + /// A pangram that contains all (or most) Arabic characters. + public const string ARABIC = + "صِف خَلقَ خَودِ كَمِثلِ الشَمسِ إِذ بَزَغَت — يَحظى الضَجيعُ بِها نَجلاءَ مِعطارِ"; + /// A pangram that contains all (or most) Azeri characters. + public const string AZERI = "Zəfər, jaketini də papağını da götür, bu axşam hava çox soyuq olacaq."; + /// A pangram that contains all (or most) Basque characters. + public const string BASQUE = "Vaudeville itxurako filmean, yogi ñaño bat jipoitzen dute Quebec-en, whiski truk"; + /// A pangram that contains all (or most) Breton characters. + public const string BRETON = + "Yec’hed mat Jakez ! Skarzhit ar gwerennoù-mañ, kavet e vo gwin betek fin ho puhez."; + /// A pangram that contains all (or most) Bulgarian characters. + public const string BULGARIAN = "Хълцащ змей плюе шофьор стигнал чуждия бивак."; + /// A pangram that contains all (or most) Catalan characters. + public const string CATALAN = + "«Dóna amor que seràs feliç!». Això, il·lús company geniüt, ja és un lluït rètol blavís d’onze kWh."; + /// A pangram that contains Traditional Chinese characters. + public const string CHINESE_TRADITIONAL = "視野無限廣,窗外有藍天"; + /// A pangram that contains Simplified Chinese characters. + public const string CHINESE_SIMPLIFIED = "Innovation in China 中国智造,慧及全球"; + /// A pangram that contains all (or most) Croatian characters. + public const string CROATIAN = "Gojazni đačić s biciklom drži hmelj i finu vatu u džepu nošnje."; + /// A pangram that contains all (or most) Czech characters. + public const string CZECH = + "Nechť již hříšné saxofony ďáblů rozezvučí síň úděsnými tóny waltzu, tanga a quickstepu."; + /// A pangram that contains all (or most) Danish characters. + public const string DANISH = + "Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Walther spillede på xylofon."; + /// A pangram that contains all (or most) Dutch characters. + public const string DUTCH = "Pa’s wijze lynx bezag vroom het fikse aquaduct."; + /// A pangram that contains all (or most) English characters. + public const string ENGLISH = "The quick brown fox jumps over the lazy dog."; + /// A pangram that contains all (or most) Esperanto characters. + public const string ESPERANTO = "Eble ĉiu kvazaŭ-deca fuŝĥoraĵo ĝojigos homtipon."; + /// A pangram that contains all (or most) Estonian characters. + public const string ESTONIAN = "Põdur Zagrebi tšellomängija-följetonist Ciqo külmetas kehvas garaažis."; + /// A pangram that contains all (or most) Finnish characters. + public const string FINNISH = + "Fahrenheit ja Celsius yrjösivät Åsan backgammon-peliin, Volkswagenissa, daiquirin ja ZX81:n yhteisvaikutuksesta."; + /// A pangram that contains all (or most) French characters. + public const string FRENCH = + "Le cœur déçu mais l'âme plutôt naïve, Louÿs rêva de crapaüter en canoë au delà des îles, près du mälströn où brûlent les novæ."; + /// A pangram that contains all (or most) Galician characters. + public const string GALICIAN = + "Necesitamos unha tipografía chuliña de cor kiwi, que lle zorregue unha labazada visual á xente."; + /// A pangram that contains all (or most) German characters. + public const string GERMAN = "Falsches Üben von Xylophonmusik quält jeden größeren Zwerg."; + /// A pangram that contains all (or most) Greek characters. + public const string GREEK = + "Ταχίστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός Takhístè alôpèx vaphês psèménè gè, draskelízei ypér nòthroý kynós."; + /// A pangram that contains all (or most) Hebrew characters. + public const string HEBREW = + "לכן חכו לי נאם יהוה ליום קומי לעד, כי משפטי לאסף גוים לקבצי ממלכות, לשפך עליהם זעמי כל חרון אפי, כי באש קנאתי תאכל כל הארץ"; + /// A pangram that contains all (or most) Hungarian characters. + public const string HUNGARIAN = "Jó foxim és don Quijote húszwattos lámpánál ülve egy pár bűvös cipőt készít."; + /// A pangram that contains all (or most) Icelandic characters. + public const string ICELANDIC = "Kæmi ný öxi hér, ykist þjófum nú bæði víl og ádrepa."; + /// A pangram that contains all (or most) Irish Gaelic characters. + public const string IRISH = "Ċuaiġ bé ṁórṡáċ le dlúṫspád fíorḟinn trí hata mo ḋea-ṗorcáin ḃig"; + /// A pangram that contains all (or most) Japanese kanas. + public const string JAPANESE = "いろはにほへと ちりぬるを わかよたれそ つねならむ うゐのおくやま けふこえて あさきゆめみし ゑひもせす(ん)"; + /// using Kanjis + public const string JAPANESE_KANJI = "色は匂へど 散りぬるを 我が世誰ぞ 常ならむ 有為の奥山 今日越えて 浅き夢見じ 酔ひもせず(ん)"; + /// A pangram that contains all (or most) Korean characters. + public const string KOREAN = "키스의 고유조건은 입술끼리 만나야 하고 특별한 기술은 필요치 않다"; + /// A pangram that contains all (or most) Latvian characters. + public const string LATVIAN = "Četri psihi faķīri vēlu vakarā zāģēja guļbūvei durvis, fonā šņācot mežam."; + /// A pangram that contains all (or most) Lithuanian characters. + public const string LITHUANIAN = "Įlinkdama fechtuotojo špaga sublykčiojusi pragręžė apvalų arbūzą"; + /// A pangram that contains all (or most) Macedonian characters. + public const string MACEDONIAN = "Ѕидарски пејзаж: шугав билмез со чудење џвака ќофте и кељ на туѓ цех."; + /// A pangram that contains all (or most) Norwegian characters. + public const string NORWEGIAN = "Jeg begynte å fortære en sandwich mens jeg kjørte taxi på vei til quiz"; + /// A pangram that contains all (or most) Polish characters. + public const string POLISH = "Jeżu klątw, spłódź Finom część gry hańb!"; + /// A pangram that contains all (or most) Portuguese characters. + public const string PORTUGUESE = + "À noite, vovô Kowalsky vê o ímã cair no pé do pingüim queixoso e vovó põe açúcar no chá de tâmaras do jabuti feliz."; + /// A pangram that contains all (or most) Romanian characters. + public const string ROMANIAN = "Înjurând pițigăiat, zoofobul comandă vexat whisky și tequila."; + /// A pangram that contains all (or most) Russian characters. + public const string RUSSIAN = + "Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства."; + /// A pangram that contains all (or most) Scottish Gaelic characters. + public const string SCOTTISH = "Mus d’fhàg Cèit-Ùna ròp Ì le ob."; + /// A pangram that contains all (or most) Serbian characters. + public const string SERBIAN = "Gojazni đačić s biciklom drži hmelj i finu vatu u džepu nošnje."; + /// A pangram that contains all (or most) Slovak characters. + public const string SLOVAK = + "Kŕdeľ šťastných ďatľov učí pri ústí Váhu mĺkveho koňa obhrýzať kôru a žrať čerstvé mäso."; + /// A pangram that contains all (or most) Slovenian characters. + public const string SLOVENIAN = "Besni dirkač iz formule žuga cehu poštarjev."; + /// A pangram that contains all (or most) Spanish characters. + public const string SPANISH = + "El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja."; + /// A pangram that contains all (or most) Swedish characters. + public const string SWEDISH = "Flygande bäckasiner söka hwila på mjuka tuvor."; + /// A pangram that contains all (or most) Turkish characters. + public const string TURKISH = "Pijamalı hasta yağız şoföre çabucak güvendi."; + /// A pangram that contains all (or most) Welsh characters. + public const string WELSH = "Parciais fy jac codi baw hud llawn dŵr ger tŷ Mabon."; } \ No newline at end of file diff --git a/Claunia.Encoding/Radix50.cs b/Claunia.Encoding/Radix50.cs index 00f87c8..f6e2ba6 100644 --- a/Claunia.Encoding/Radix50.cs +++ b/Claunia.Encoding/Radix50.cs @@ -26,324 +26,323 @@ using System; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an Radix-50 (PDP-11) character encoding of Unicode characters. +public class Radix50 : SingleByteEncoding { - /// Represents an Radix-50 (PDP-11) character encoding of Unicode characters. - public class Radix50 : SingleByteEncoding + /// + public override string BodyName => "radix50"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Western European (Radix-50)"; + /// + public override string HeaderName => "radix50"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => false; + + /// The Radix-50 to Unicode character map, when bits are shifted right + protected override char[] CharTable => new[] { - /// - public override string BodyName => "radix50"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Western European (Radix-50)"; - /// - public override string HeaderName => "radix50"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + '\u0020', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => false; + // 0x08 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - /// The Radix-50 to Unicode character map, when bits are shifted right - protected override char[] CharTable => new[] - { - // 0x00 - '\u0020', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x10 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x08 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x18 + '\u0058', '\u0059', '\u005A', '\u0024', '\u002E', '\u0025', '\u0030', '\u0031', - // 0x10 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x20 + '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', '\u0038', '\u0039', - // 0x18 - '\u0058', '\u0059', '\u005A', '\u0024', '\u002E', '\u0025', '\u0030', '\u0031', + // 0x28 (unused but legal) + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x20 - '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', '\u0038', '\u0039', + // 0x30 (unused but legal) + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x28 (unused but legal) - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0x38 (unused but legal) + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' + }; - // 0x30 (unused but legal) - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + /// Calculates the number of bytes produced by encoding the characters in the specified . + /// The number of bytes produced by encoding the specified characters. + /// The containing the set of characters to encode. + public override int GetByteCount(string s) + { + if(s == null) + throw new ArgumentNullException(nameof(s)); - // 0x38 (unused but legal) - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000' - }; - - /// Calculates the number of bytes produced by encoding the characters in the specified . - /// The number of bytes produced by encoding the specified characters. - /// The containing the set of characters to encode. - public override int GetByteCount(string s) - { - if(s == null) - throw new ArgumentNullException(nameof(s)); - - return s.Length * 6 % 8 > 0 ? (s.Length * 6 / 8) + 1 : s.Length * 6 / 8; - } - - /// Calculates the number of bytes produced by encoding a set of characters from the specified character array. - /// The number of bytes produced by encoding the specified characters. - /// The character array containing the set of characters to encode. - /// The index of the first character to encode. - /// The number of characters to encode. - public override int GetByteCount(char[] chars, int index, int count) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - if(index < 0 || - index >= chars.Length) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0 || - index + count > chars.Length) - throw new ArgumentOutOfRangeException(nameof(index)); - - return count * 6 % 8 > 0 ? (count * 6 / 8) + 1 : count * 6 / 8; - } - - /// Calculates the number of bytes produced by encoding all the characters in the specified character array. - /// The number of bytes produced by encoding all the characters in the specified character array. - /// The character array containing the characters to encode. - public override int GetByteCount(char[] chars) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - return chars.Length * 6 % 8 > 0 ? (chars.Length * 6 / 8) + 1 : chars.Length * 6 / 8; - } - - /// Encodes a set of characters from the specified character array into a sequence of bytes. - /// A byte array containing the results of encoding the specified set of characters. - /// The character array containing the set of characters to encode. - /// The index of the first character to encode. - /// The number of characters to encode. - public override byte[] GetBytes(char[] chars, int index, int count) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - if(index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - - if(count + index > chars.Length) - throw new ArgumentOutOfRangeException(nameof(count)); - - byte[] bytes = new byte[count * 6 % 8 > 0 ? (count * 6 / 8) + 1 : count * 6 / 8]; - int outPos = 0; - - for(int i = 0; i < count; i++) - { - byte thisByte = GetByte(chars[index + i]); - - switch(i % 4) - { - case 0: - if(outPos >= bytes.Length) - break; - - bytes[outPos] = (byte)(thisByte << 2); - - break; - case 1: - if(outPos + 1 >= bytes.Length) - break; - - bytes[outPos] += (byte)((thisByte & 0x30) >> 4); - bytes[outPos + 1] = (byte)((thisByte & 0xF) << 4); - - break; - case 2: - if(outPos + 2 >= bytes.Length) - break; - - bytes[outPos + 1] += (byte)((thisByte & 0x3C) >> 2); - bytes[outPos + 2] = (byte)((thisByte & 0x3) << 6); - - break; - case 3: - if(outPos + 2 >= bytes.Length) - break; - - bytes[outPos + 2] += (byte)(thisByte & 0x3F); - outPos += 3; - - break; - } - } - - return bytes; - } - - /// Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array. - /// The number of characters produced by decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - /// The index of the first byte to decode. - /// The number of bytes to decode. - public override int GetCharCount(byte[] bytes, int index, int count) - { - if(bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if(index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - - if(count + index > bytes.Length) - throw new ArgumentOutOfRangeException(nameof(count)); - - return count * 8 / 6; - } - - /// Decodes a sequence of bytes from the specified byte array into a set of characters. - /// The chars. - /// The byte array containing the sequence of bytes to decode. - /// The index of the first byte to decode. - /// The number of bytes to decode. - public override char[] GetChars(byte[] bytes, int index, int count) - { - if(bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if(index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - - if(count + index > bytes.Length) - throw new ArgumentOutOfRangeException(nameof(count)); - - char[] chars = new char[count * 8 / 6]; - - // aaaaaabb bbbbcccc ccdddddd - - int outPos = 0; - - for(int i = 0; i < count; i++) - { - byte rd50; - - switch(i % 3) - { - case 0: - rd50 = (byte)((bytes[index + i] & 0xFC) >> 2); - chars[outPos] = GetChar(rd50); - outPos++; - - break; - case 1: - rd50 = (byte)(((bytes[index + i - 1] & 0x03) << 4) + ((bytes[index + i] & 0xF0) >> 4)); - chars[outPos] = GetChar(rd50); - outPos++; - - break; - case 2: - rd50 = (byte)(((bytes[index + i - 1] & 0x0F) << 2) + ((bytes[index + i] & 0xC0) >> 6)); - chars[outPos] = GetChar(rd50); - chars[outPos + 1] = GetChar((byte)(bytes[index + i] & 0x3F)); - outPos += 2; - - break; - } - } - - return chars; - } - - /// Calculates the maximum number of bytes produced by encoding the specified number of characters. - /// The maximum number of bytes produced by encoding the specified number of characters. - /// The number of characters to encode. - public override int GetMaxByteCount(int charCount) - { - if(charCount < 0) - throw new ArgumentOutOfRangeException(nameof(charCount)); - - return charCount * 6 % 8 > 0 ? (charCount * 6 / 8) + 1 : charCount * 6 / 8; - } - - /// Calculates the maximum number of characters produced by decoding the specified number of bytes. - /// The maximum number of characters produced by decoding the specified number of bytes. - /// The number of bytes to decode. - public override int GetMaxCharCount(int byteCount) - { - if(byteCount < 0) - throw new ArgumentOutOfRangeException(nameof(byteCount)); - - return byteCount * 8 / 6; - } - - /// Converts a Apple II character to an Unicode character - /// Unicode character. - /// Apple II character. - char GetChar(byte character) => CharTable[character & 0x3F]; - - /// Converts a Unicode character to an Apple II character - /// Apple II character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0020' => 0x00, - '\u0041' => 0x01, - '\u0042' => 0x02, - '\u0043' => 0x03, - '\u0044' => 0x04, - '\u0045' => 0x05, - '\u0046' => 0x06, - '\u0047' => 0x07, - '\u0048' => 0x08, - '\u0049' => 0x09, - '\u004A' => 0x0A, - '\u004B' => 0x0B, - '\u004C' => 0x0C, - '\u004D' => 0x0D, - '\u004E' => 0x0E, - '\u004F' => 0x0F, - '\u0050' => 0x10, - '\u0051' => 0x11, - '\u0052' => 0x12, - '\u0053' => 0x13, - '\u0054' => 0x14, - '\u0055' => 0x15, - '\u0056' => 0x16, - '\u0057' => 0x17, - '\u0058' => 0x18, - '\u0059' => 0x19, - '\u005A' => 0x1A, - '\u0024' => 0x1B, - '\u002E' => 0x1C, - '\u0025' => 0x1D, - '\u0030' => 0x1E, - '\u0031' => 0x1F, - '\u0032' => 0x20, - '\u0033' => 0x21, - '\u0034' => 0x22, - '\u0035' => 0x23, - '\u0036' => 0x24, - '\u0037' => 0x25, - '\u0038' => 0x26, - '\u0039' => 0x27, - _ => 0x1C - }; + return s.Length * 6 % 8 > 0 ? (s.Length * 6 / 8) + 1 : s.Length * 6 / 8; } + + /// Calculates the number of bytes produced by encoding a set of characters from the specified character array. + /// The number of bytes produced by encoding the specified characters. + /// The character array containing the set of characters to encode. + /// The index of the first character to encode. + /// The number of characters to encode. + public override int GetByteCount(char[] chars, int index, int count) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + if(index < 0 || + index >= chars.Length) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0 || + index + count > chars.Length) + throw new ArgumentOutOfRangeException(nameof(index)); + + return count * 6 % 8 > 0 ? (count * 6 / 8) + 1 : count * 6 / 8; + } + + /// Calculates the number of bytes produced by encoding all the characters in the specified character array. + /// The number of bytes produced by encoding all the characters in the specified character array. + /// The character array containing the characters to encode. + public override int GetByteCount(char[] chars) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + return chars.Length * 6 % 8 > 0 ? (chars.Length * 6 / 8) + 1 : chars.Length * 6 / 8; + } + + /// Encodes a set of characters from the specified character array into a sequence of bytes. + /// A byte array containing the results of encoding the specified set of characters. + /// The character array containing the set of characters to encode. + /// The index of the first character to encode. + /// The number of characters to encode. + public override byte[] GetBytes(char[] chars, int index, int count) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + if(index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0) + throw new ArgumentOutOfRangeException(nameof(count)); + + if(count + index > chars.Length) + throw new ArgumentOutOfRangeException(nameof(count)); + + byte[] bytes = new byte[count * 6 % 8 > 0 ? (count * 6 / 8) + 1 : count * 6 / 8]; + int outPos = 0; + + for(int i = 0; i < count; i++) + { + byte thisByte = GetByte(chars[index + i]); + + switch(i % 4) + { + case 0: + if(outPos >= bytes.Length) + break; + + bytes[outPos] = (byte)(thisByte << 2); + + break; + case 1: + if(outPos + 1 >= bytes.Length) + break; + + bytes[outPos] += (byte)((thisByte & 0x30) >> 4); + bytes[outPos + 1] = (byte)((thisByte & 0xF) << 4); + + break; + case 2: + if(outPos + 2 >= bytes.Length) + break; + + bytes[outPos + 1] += (byte)((thisByte & 0x3C) >> 2); + bytes[outPos + 2] = (byte)((thisByte & 0x3) << 6); + + break; + case 3: + if(outPos + 2 >= bytes.Length) + break; + + bytes[outPos + 2] += (byte)(thisByte & 0x3F); + outPos += 3; + + break; + } + } + + return bytes; + } + + /// Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array. + /// The number of characters produced by decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + /// The index of the first byte to decode. + /// The number of bytes to decode. + public override int GetCharCount(byte[] bytes, int index, int count) + { + if(bytes == null) + throw new ArgumentNullException(nameof(bytes)); + + if(index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0) + throw new ArgumentOutOfRangeException(nameof(count)); + + if(count + index > bytes.Length) + throw new ArgumentOutOfRangeException(nameof(count)); + + return count * 8 / 6; + } + + /// Decodes a sequence of bytes from the specified byte array into a set of characters. + /// The chars. + /// The byte array containing the sequence of bytes to decode. + /// The index of the first byte to decode. + /// The number of bytes to decode. + public override char[] GetChars(byte[] bytes, int index, int count) + { + if(bytes == null) + throw new ArgumentNullException(nameof(bytes)); + + if(index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0) + throw new ArgumentOutOfRangeException(nameof(count)); + + if(count + index > bytes.Length) + throw new ArgumentOutOfRangeException(nameof(count)); + + char[] chars = new char[count * 8 / 6]; + + // aaaaaabb bbbbcccc ccdddddd + + int outPos = 0; + + for(int i = 0; i < count; i++) + { + byte rd50; + + switch(i % 3) + { + case 0: + rd50 = (byte)((bytes[index + i] & 0xFC) >> 2); + chars[outPos] = GetChar(rd50); + outPos++; + + break; + case 1: + rd50 = (byte)(((bytes[index + i - 1] & 0x03) << 4) + ((bytes[index + i] & 0xF0) >> 4)); + chars[outPos] = GetChar(rd50); + outPos++; + + break; + case 2: + rd50 = (byte)(((bytes[index + i - 1] & 0x0F) << 2) + ((bytes[index + i] & 0xC0) >> 6)); + chars[outPos] = GetChar(rd50); + chars[outPos + 1] = GetChar((byte)(bytes[index + i] & 0x3F)); + outPos += 2; + + break; + } + } + + return chars; + } + + /// Calculates the maximum number of bytes produced by encoding the specified number of characters. + /// The maximum number of bytes produced by encoding the specified number of characters. + /// The number of characters to encode. + public override int GetMaxByteCount(int charCount) + { + if(charCount < 0) + throw new ArgumentOutOfRangeException(nameof(charCount)); + + return charCount * 6 % 8 > 0 ? (charCount * 6 / 8) + 1 : charCount * 6 / 8; + } + + /// Calculates the maximum number of characters produced by decoding the specified number of bytes. + /// The maximum number of characters produced by decoding the specified number of bytes. + /// The number of bytes to decode. + public override int GetMaxCharCount(int byteCount) + { + if(byteCount < 0) + throw new ArgumentOutOfRangeException(nameof(byteCount)); + + return byteCount * 8 / 6; + } + + /// Converts a Apple II character to an Unicode character + /// Unicode character. + /// Apple II character. + char GetChar(byte character) => CharTable[character & 0x3F]; + + /// Converts a Unicode character to an Apple II character + /// Apple II character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0020' => 0x00, + '\u0041' => 0x01, + '\u0042' => 0x02, + '\u0043' => 0x03, + '\u0044' => 0x04, + '\u0045' => 0x05, + '\u0046' => 0x06, + '\u0047' => 0x07, + '\u0048' => 0x08, + '\u0049' => 0x09, + '\u004A' => 0x0A, + '\u004B' => 0x0B, + '\u004C' => 0x0C, + '\u004D' => 0x0D, + '\u004E' => 0x0E, + '\u004F' => 0x0F, + '\u0050' => 0x10, + '\u0051' => 0x11, + '\u0052' => 0x12, + '\u0053' => 0x13, + '\u0054' => 0x14, + '\u0055' => 0x15, + '\u0056' => 0x16, + '\u0057' => 0x17, + '\u0058' => 0x18, + '\u0059' => 0x19, + '\u005A' => 0x1A, + '\u0024' => 0x1B, + '\u002E' => 0x1C, + '\u0025' => 0x1D, + '\u0030' => 0x1E, + '\u0031' => 0x1F, + '\u0032' => 0x20, + '\u0033' => 0x21, + '\u0034' => 0x22, + '\u0035' => 0x23, + '\u0036' => 0x24, + '\u0037' => 0x25, + '\u0038' => 0x26, + '\u0039' => 0x27, + _ => 0x1C + }; } \ No newline at end of file diff --git a/Claunia.Encoding/SingleByteEncoding.cs b/Claunia.Encoding/SingleByteEncoding.cs index 8402c73..c6b8057 100644 --- a/Claunia.Encoding/SingleByteEncoding.cs +++ b/Claunia.Encoding/SingleByteEncoding.cs @@ -1,343 +1,342 @@ using System; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// +/// Implements a class that converts to/from a single byte codepage and UTF-16 representable strings +/// +public abstract class SingleByteEncoding : Encoding { /// - /// Implements a class that converts to/from a single byte codepage and UTF-16 representable strings + /// Character conversion table /// - public abstract class SingleByteEncoding : Encoding + protected abstract char[] CharTable { get; } + + /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content. + public abstract override bool IsBrowserDisplay { get; } + + /// Gets a value indicating whether the current encoding can be used by browser clients for saving content. + public abstract override bool IsBrowserSave { get; } + + /// + /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying + /// content. + /// + public abstract override bool IsMailNewsDisplay { get; } + + /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content. + public abstract override bool IsMailNewsSave { get; } + + /// Gets a value indicating whether the current encoding is read-only. + /// The is single byte. + public abstract override bool IsReadOnly { get; } + + /// Gets a value indicating whether the current encoding uses single-byte code points. + public abstract override bool IsSingleByte { get; } + + /// Gets the code page identifier of the current Encoding. + public abstract override int CodePage { get; } + + /// Gets a name for the current encoding that can be used with mail agent body tags + public abstract override string BodyName { get; } + + /// Gets a name for the current encoding that can be used with mail agent header tags + public abstract override string HeaderName { get; } + + /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding. + public abstract override string WebName { get; } + + /// Gets the human-readable description of the current encoding. + public abstract override string EncodingName { get; } + + /// Gets the Windows operating system code page that most closely corresponds to the current encoding. + public abstract override int WindowsCodePage { get; } + + /// Calculates the number of bytes produced by encoding the characters in the specified . + /// The number of bytes produced by encoding the specified characters. + /// The containing the set of characters to encode. + public override int GetByteCount(string s) { - /// - /// Character conversion table - /// - protected abstract char[] CharTable { get; } + if(s == null) + throw new ArgumentNullException(nameof(s)); - /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content. - public abstract override bool IsBrowserDisplay { get; } - - /// Gets a value indicating whether the current encoding can be used by browser clients for saving content. - public abstract override bool IsBrowserSave { get; } - - /// - /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying - /// content. - /// - public abstract override bool IsMailNewsDisplay { get; } - - /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content. - public abstract override bool IsMailNewsSave { get; } - - /// Gets a value indicating whether the current encoding is read-only. - /// The is single byte. - public abstract override bool IsReadOnly { get; } - - /// Gets a value indicating whether the current encoding uses single-byte code points. - public abstract override bool IsSingleByte { get; } - - /// Gets the code page identifier of the current Encoding. - public abstract override int CodePage { get; } - - /// Gets a name for the current encoding that can be used with mail agent body tags - public abstract override string BodyName { get; } - - /// Gets a name for the current encoding that can be used with mail agent header tags - public abstract override string HeaderName { get; } - - /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding. - public abstract override string WebName { get; } - - /// Gets the human-readable description of the current encoding. - public abstract override string EncodingName { get; } - - /// Gets the Windows operating system code page that most closely corresponds to the current encoding. - public abstract override int WindowsCodePage { get; } - - /// Calculates the number of bytes produced by encoding the characters in the specified . - /// The number of bytes produced by encoding the specified characters. - /// The containing the set of characters to encode. - public override int GetByteCount(string s) - { - if(s == null) - throw new ArgumentNullException(nameof(s)); - - return s.Length; - } - - /// Calculates the number of bytes produced by encoding a set of characters from the specified character array. - /// The number of bytes produced by encoding the specified characters. - /// The character array containing the set of characters to encode. - /// The index of the first character to encode. - /// The number of characters to encode. - public override int GetByteCount(char[] chars, int index, int count) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - if(index < 0 || - index >= chars.Length) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0 || - index + count > chars.Length) - throw new ArgumentOutOfRangeException(nameof(index)); - - return count; - } - - /// Calculates the number of bytes produced by encoding all the characters in the specified character array. - /// The number of bytes produced by encoding all the characters in the specified character array. - /// The character array containing the characters to encode. - public override int GetByteCount(char[] chars) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - return chars.Length; - } - - /// Encodes a set of characters from the specified into the specified byte array. - /// The actual number of bytes written into bytes. - /// The containing the set of characters to encode. - /// The index of the first character to encode. - /// The number of characters to encode. - /// The byte array to contain the resulting sequence of bytes. - /// The index at which to start writing the resulting sequence of bytes. - public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) => - GetBytes(s.ToCharArray(), charIndex, charCount, bytes, byteIndex); - - /// Encodes all the characters in the specified string into a sequence of bytes. - /// A byte array containing the results of encoding the specified set of characters. - /// The string containing the characters to encode. - public override byte[] GetBytes(string s) - { - if(s == null) - throw new ArgumentNullException(nameof(s)); - - return GetBytes(s.ToCharArray(), 0, s.Length); - } - - /// Encodes a set of characters from the specified character array into the specified byte array. - /// The actual number of bytes written into bytes. - /// The character array containing the set of characters to encode. - /// The index of the first character to encode. - /// The number of characters to encode. - /// The byte array to contain the resulting sequence of bytes. - /// The index at which to start writing the resulting sequence of bytes. - public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - if(bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if(charIndex < 0) - throw new ArgumentOutOfRangeException(nameof(charIndex)); - - if(charCount < 0) - throw new ArgumentOutOfRangeException(nameof(charCount)); - - if(byteIndex < 0) - throw new ArgumentOutOfRangeException(nameof(byteIndex)); - - if(charIndex >= chars.Length) - throw new ArgumentOutOfRangeException(nameof(charIndex)); - - if(charCount + charIndex > chars.Length) - throw new ArgumentOutOfRangeException(nameof(charCount)); - - if(byteIndex >= bytes.Length) - throw new ArgumentOutOfRangeException(nameof(byteIndex)); - - if(byteIndex + charCount > bytes.Length) - throw new ArgumentException(nameof(bytes)); - - byte[] temp = GetBytes(chars, charIndex, charCount); - - for(int i = 0; i < temp.Length; i++) - bytes[i + byteIndex] = temp[i]; - - return charCount; - } - - /// Encodes a set of characters from the specified character array into a sequence of bytes. - /// A byte array containing the results of encoding the specified set of characters. - /// The character array containing the set of characters to encode. - /// The index of the first character to encode. - /// The number of characters to encode. - public override byte[] GetBytes(char[] chars, int index, int count) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - if(index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - - if(count + index > chars.Length) - throw new ArgumentOutOfRangeException(nameof(count)); - - byte[] bytes = new byte[count]; - - for(int i = 0; i < count; i++) - bytes[i] = GetByte(chars[index + i]); - - return bytes; - } - - /// Encodes all the characters in the specified character array into a sequence of bytes. - /// A byte array containing the results of encoding the specified set of characters. - /// The character array containing the characters to encode. - public override byte[] GetBytes(char[] chars) => GetBytes(chars, 0, chars.Length); - - /// Calculates the number of characters produced by decoding all the bytes in the specified byte array. - /// The number of characters produced by decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - public override int GetCharCount(byte[] bytes) => GetCharCount(bytes, 0, bytes.Length); - - /// Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array. - /// The number of characters produced by decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - /// The index of the first byte to decode. - /// The number of bytes to decode. - public override int GetCharCount(byte[] bytes, int index, int count) - { - if(bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if(index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - - if(count + index > bytes.Length) - throw new ArgumentOutOfRangeException(nameof(count)); - - return count; - } - - /// Decodes a sequence of bytes from the specified byte array into the specified character array. - /// The actual number of characters written into chars. - /// The byte array containing the sequence of bytes to decode. - /// The index of the first byte to decode. - /// The number of bytes to decode. - /// The character array to contain the resulting set of characters. - /// The index at which to start writing the resulting set of characters. - public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) - { - if(bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - if(byteIndex < 0) - throw new ArgumentOutOfRangeException(nameof(byteIndex)); - - if(byteCount < 0) - throw new ArgumentOutOfRangeException(nameof(byteCount)); - - if(charIndex < 0) - throw new ArgumentOutOfRangeException(nameof(charIndex)); - - if(byteIndex >= bytes.Length) - throw new ArgumentOutOfRangeException(nameof(byteIndex)); - - if(byteCount + byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException(nameof(byteCount)); - - if(charIndex >= chars.Length) - throw new ArgumentOutOfRangeException(nameof(charIndex)); - - if(charIndex + byteCount > chars.Length) - throw new ArgumentException(nameof(chars)); - - char[] temp = GetChars(bytes, byteIndex, byteCount); - - for(int i = 0; i < temp.Length; i++) - chars[i + charIndex] = temp[i]; - - return byteCount; - } - - /// Decodes all the bytes in the specified byte array into a set of characters. - /// A character array containing the results of decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - public override char[] GetChars(byte[] bytes) => GetChars(bytes, 0, bytes.Length); - - /// Decodes a sequence of bytes from the specified byte array into a set of characters. - /// The chars. - /// The byte array containing the sequence of bytes to decode. - /// The index of the first byte to decode. - /// The number of bytes to decode. - public override char[] GetChars(byte[] bytes, int index, int count) - { - if(bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if(index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - - if(count + index > bytes.Length) - throw new ArgumentOutOfRangeException(nameof(count)); - - char[] chars = new char[count]; - - for(int i = 0; i < count; i++) - chars[i] = GetChar(bytes[index + i]); - - return chars; - } - - /// Calculates the maximum number of bytes produced by encoding the specified number of characters. - /// The maximum number of bytes produced by encoding the specified number of characters. - /// The number of characters to encode. - public override int GetMaxByteCount(int charCount) - { - if(charCount < 0) - throw new ArgumentOutOfRangeException(nameof(charCount)); - - return charCount; - } - - /// Calculates the maximum number of characters produced by decoding the specified number of bytes. - /// The maximum number of characters produced by decoding the specified number of bytes. - /// The number of bytes to decode. - public override int GetMaxCharCount(int byteCount) - { - if(byteCount < 0) - throw new ArgumentOutOfRangeException(nameof(byteCount)); - - return byteCount; - } - - /// Returns a sequence of bytes that specifies the encoding used. - /// A byte array of length zero, as a preamble is not required. - public override byte[] GetPreamble() => new byte[0]; - - /// Decodes all the bytes in the specified byte array into a string. - /// A string that contains the results of decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - public override string GetString(byte[] bytes) => GetString(bytes, 0, bytes.Length); - - /// Decodes a sequence of bytes from the specified byte array into a string. - /// A string that contains the results of decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - /// The index of the first byte to decode. - /// The number of bytes to decode. - public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count)); - - /// Converts a codepage character to an Unicode character - /// Unicode character. - /// Codepage character. - char GetChar(byte character) => CharTable[character]; - - private protected abstract byte GetByte(char character); + return s.Length; } + + /// Calculates the number of bytes produced by encoding a set of characters from the specified character array. + /// The number of bytes produced by encoding the specified characters. + /// The character array containing the set of characters to encode. + /// The index of the first character to encode. + /// The number of characters to encode. + public override int GetByteCount(char[] chars, int index, int count) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + if(index < 0 || + index >= chars.Length) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0 || + index + count > chars.Length) + throw new ArgumentOutOfRangeException(nameof(index)); + + return count; + } + + /// Calculates the number of bytes produced by encoding all the characters in the specified character array. + /// The number of bytes produced by encoding all the characters in the specified character array. + /// The character array containing the characters to encode. + public override int GetByteCount(char[] chars) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + return chars.Length; + } + + /// Encodes a set of characters from the specified into the specified byte array. + /// The actual number of bytes written into bytes. + /// The containing the set of characters to encode. + /// The index of the first character to encode. + /// The number of characters to encode. + /// The byte array to contain the resulting sequence of bytes. + /// The index at which to start writing the resulting sequence of bytes. + public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) => + GetBytes(s.ToCharArray(), charIndex, charCount, bytes, byteIndex); + + /// Encodes all the characters in the specified string into a sequence of bytes. + /// A byte array containing the results of encoding the specified set of characters. + /// The string containing the characters to encode. + public override byte[] GetBytes(string s) + { + if(s == null) + throw new ArgumentNullException(nameof(s)); + + return GetBytes(s.ToCharArray(), 0, s.Length); + } + + /// Encodes a set of characters from the specified character array into the specified byte array. + /// The actual number of bytes written into bytes. + /// The character array containing the set of characters to encode. + /// The index of the first character to encode. + /// The number of characters to encode. + /// The byte array to contain the resulting sequence of bytes. + /// The index at which to start writing the resulting sequence of bytes. + public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + if(bytes == null) + throw new ArgumentNullException(nameof(bytes)); + + if(charIndex < 0) + throw new ArgumentOutOfRangeException(nameof(charIndex)); + + if(charCount < 0) + throw new ArgumentOutOfRangeException(nameof(charCount)); + + if(byteIndex < 0) + throw new ArgumentOutOfRangeException(nameof(byteIndex)); + + if(charIndex >= chars.Length) + throw new ArgumentOutOfRangeException(nameof(charIndex)); + + if(charCount + charIndex > chars.Length) + throw new ArgumentOutOfRangeException(nameof(charCount)); + + if(byteIndex >= bytes.Length) + throw new ArgumentOutOfRangeException(nameof(byteIndex)); + + if(byteIndex + charCount > bytes.Length) + throw new ArgumentException(nameof(bytes)); + + byte[] temp = GetBytes(chars, charIndex, charCount); + + for(int i = 0; i < temp.Length; i++) + bytes[i + byteIndex] = temp[i]; + + return charCount; + } + + /// Encodes a set of characters from the specified character array into a sequence of bytes. + /// A byte array containing the results of encoding the specified set of characters. + /// The character array containing the set of characters to encode. + /// The index of the first character to encode. + /// The number of characters to encode. + public override byte[] GetBytes(char[] chars, int index, int count) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + if(index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0) + throw new ArgumentOutOfRangeException(nameof(count)); + + if(count + index > chars.Length) + throw new ArgumentOutOfRangeException(nameof(count)); + + byte[] bytes = new byte[count]; + + for(int i = 0; i < count; i++) + bytes[i] = GetByte(chars[index + i]); + + return bytes; + } + + /// Encodes all the characters in the specified character array into a sequence of bytes. + /// A byte array containing the results of encoding the specified set of characters. + /// The character array containing the characters to encode. + public override byte[] GetBytes(char[] chars) => GetBytes(chars, 0, chars.Length); + + /// Calculates the number of characters produced by decoding all the bytes in the specified byte array. + /// The number of characters produced by decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + public override int GetCharCount(byte[] bytes) => GetCharCount(bytes, 0, bytes.Length); + + /// Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array. + /// The number of characters produced by decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + /// The index of the first byte to decode. + /// The number of bytes to decode. + public override int GetCharCount(byte[] bytes, int index, int count) + { + if(bytes == null) + throw new ArgumentNullException(nameof(bytes)); + + if(index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0) + throw new ArgumentOutOfRangeException(nameof(count)); + + if(count + index > bytes.Length) + throw new ArgumentOutOfRangeException(nameof(count)); + + return count; + } + + /// Decodes a sequence of bytes from the specified byte array into the specified character array. + /// The actual number of characters written into chars. + /// The byte array containing the sequence of bytes to decode. + /// The index of the first byte to decode. + /// The number of bytes to decode. + /// The character array to contain the resulting set of characters. + /// The index at which to start writing the resulting set of characters. + public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) + { + if(bytes == null) + throw new ArgumentNullException(nameof(bytes)); + + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + if(byteIndex < 0) + throw new ArgumentOutOfRangeException(nameof(byteIndex)); + + if(byteCount < 0) + throw new ArgumentOutOfRangeException(nameof(byteCount)); + + if(charIndex < 0) + throw new ArgumentOutOfRangeException(nameof(charIndex)); + + if(byteIndex >= bytes.Length) + throw new ArgumentOutOfRangeException(nameof(byteIndex)); + + if(byteCount + byteIndex > bytes.Length) + throw new ArgumentOutOfRangeException(nameof(byteCount)); + + if(charIndex >= chars.Length) + throw new ArgumentOutOfRangeException(nameof(charIndex)); + + if(charIndex + byteCount > chars.Length) + throw new ArgumentException(nameof(chars)); + + char[] temp = GetChars(bytes, byteIndex, byteCount); + + for(int i = 0; i < temp.Length; i++) + chars[i + charIndex] = temp[i]; + + return byteCount; + } + + /// Decodes all the bytes in the specified byte array into a set of characters. + /// A character array containing the results of decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + public override char[] GetChars(byte[] bytes) => GetChars(bytes, 0, bytes.Length); + + /// Decodes a sequence of bytes from the specified byte array into a set of characters. + /// The chars. + /// The byte array containing the sequence of bytes to decode. + /// The index of the first byte to decode. + /// The number of bytes to decode. + public override char[] GetChars(byte[] bytes, int index, int count) + { + if(bytes == null) + throw new ArgumentNullException(nameof(bytes)); + + if(index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0) + throw new ArgumentOutOfRangeException(nameof(count)); + + if(count + index > bytes.Length) + throw new ArgumentOutOfRangeException(nameof(count)); + + char[] chars = new char[count]; + + for(int i = 0; i < count; i++) + chars[i] = GetChar(bytes[index + i]); + + return chars; + } + + /// Calculates the maximum number of bytes produced by encoding the specified number of characters. + /// The maximum number of bytes produced by encoding the specified number of characters. + /// The number of characters to encode. + public override int GetMaxByteCount(int charCount) + { + if(charCount < 0) + throw new ArgumentOutOfRangeException(nameof(charCount)); + + return charCount; + } + + /// Calculates the maximum number of characters produced by decoding the specified number of bytes. + /// The maximum number of characters produced by decoding the specified number of bytes. + /// The number of bytes to decode. + public override int GetMaxCharCount(int byteCount) + { + if(byteCount < 0) + throw new ArgumentOutOfRangeException(nameof(byteCount)); + + return byteCount; + } + + /// Returns a sequence of bytes that specifies the encoding used. + /// A byte array of length zero, as a preamble is not required. + public override byte[] GetPreamble() => new byte[0]; + + /// Decodes all the bytes in the specified byte array into a string. + /// A string that contains the results of decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + public override string GetString(byte[] bytes) => GetString(bytes, 0, bytes.Length); + + /// Decodes a sequence of bytes from the specified byte array into a string. + /// A string that contains the results of decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + /// The index of the first byte to decode. + /// The number of bytes to decode. + public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count)); + + /// Converts a codepage character to an Unicode character + /// Unicode character. + /// Codepage character. + char GetChar(byte character) => CharTable[character]; + + private protected abstract byte GetByte(char character); } \ No newline at end of file diff --git a/Claunia.Encoding/SingleByteEncodingWithRunes.cs b/Claunia.Encoding/SingleByteEncodingWithRunes.cs index 60fccd0..e21f8bb 100644 --- a/Claunia.Encoding/SingleByteEncodingWithRunes.cs +++ b/Claunia.Encoding/SingleByteEncodingWithRunes.cs @@ -3,373 +3,372 @@ using System.Globalization; using System.Linq; using System.Text; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// +/// Implements a class that converts to/from a single byte codepage and strings that contains elements that need +/// surrogates in UTF-16, using runes. +/// +public abstract class SingleByteEncodingWithRunes : Encoding { /// - /// Implements a class that converts to/from a single byte codepage and strings that contains elements that need - /// surrogates in UTF-16, using runes. + /// Rune conversion table /// - public abstract class SingleByteEncodingWithRunes : Encoding + protected abstract Rune[] CharTable { get; } + + /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content. + public abstract override bool IsBrowserDisplay { get; } + + /// Gets a value indicating whether the current encoding can be used by browser clients for saving content. + public abstract override bool IsBrowserSave { get; } + + /// + /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying + /// content. + /// + public abstract override bool IsMailNewsDisplay { get; } + + /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content. + public abstract override bool IsMailNewsSave { get; } + + /// Gets a value indicating whether the current encoding is read-only. + /// The is single byte. + public abstract override bool IsReadOnly { get; } + + /// Gets a value indicating whether the current encoding uses single-byte code points. + public abstract override bool IsSingleByte { get; } + + /// Gets the code page identifier of the current Encoding. + public abstract override int CodePage { get; } + + /// Gets a name for the current encoding that can be used with mail agent body tags + public abstract override string BodyName { get; } + + /// Gets a name for the current encoding that can be used with mail agent header tags + public abstract override string HeaderName { get; } + + /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding. + public abstract override string WebName { get; } + + /// Gets the human-readable description of the current encoding. + public abstract override string EncodingName { get; } + + /// Gets the Windows operating system code page that most closely corresponds to the current encoding. + public abstract override int WindowsCodePage { get; } + + /// Calculates the number of bytes produced by encoding the characters in the specified . + /// The number of bytes produced by encoding the specified characters. + /// The containing the set of characters to encode. + public override int GetByteCount(string s) { - /// - /// Rune conversion table - /// - protected abstract Rune[] CharTable { get; } + if(s == null) + throw new ArgumentNullException(nameof(s)); - /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content. - public abstract override bool IsBrowserDisplay { get; } - - /// Gets a value indicating whether the current encoding can be used by browser clients for saving content. - public abstract override bool IsBrowserSave { get; } - - /// - /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying - /// content. - /// - public abstract override bool IsMailNewsDisplay { get; } - - /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content. - public abstract override bool IsMailNewsSave { get; } - - /// Gets a value indicating whether the current encoding is read-only. - /// The is single byte. - public abstract override bool IsReadOnly { get; } - - /// Gets a value indicating whether the current encoding uses single-byte code points. - public abstract override bool IsSingleByte { get; } - - /// Gets the code page identifier of the current Encoding. - public abstract override int CodePage { get; } - - /// Gets a name for the current encoding that can be used with mail agent body tags - public abstract override string BodyName { get; } - - /// Gets a name for the current encoding that can be used with mail agent header tags - public abstract override string HeaderName { get; } - - /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding. - public abstract override string WebName { get; } - - /// Gets the human-readable description of the current encoding. - public abstract override string EncodingName { get; } - - /// Gets the Windows operating system code page that most closely corresponds to the current encoding. - public abstract override int WindowsCodePage { get; } - - /// Calculates the number of bytes produced by encoding the characters in the specified . - /// The number of bytes produced by encoding the specified characters. - /// The containing the set of characters to encode. - public override int GetByteCount(string s) - { - if(s == null) - throw new ArgumentNullException(nameof(s)); - - return new StringInfo(s).LengthInTextElements; - } - - /// Calculates the number of bytes produced by encoding a set of characters from the specified character array. - /// The number of bytes produced by encoding the specified characters. - /// The character array containing the set of characters to encode. - /// The index of the first character to encode. - /// The number of characters to encode. - public override int GetByteCount(char[] chars, int index, int count) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - if(index < 0 || - index >= chars.Length) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0 || - index + count > chars.Length) - throw new ArgumentOutOfRangeException(nameof(index)); - - return new StringInfo(new string(chars, index, count)).LengthInTextElements; - } - - /// Calculates the number of bytes produced by encoding all the characters in the specified character array. - /// The number of bytes produced by encoding all the characters in the specified character array. - /// The character array containing the characters to encode. - public override int GetByteCount(char[] chars) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - return new StringInfo(new string(chars)).LengthInTextElements; - } - - /// Encodes a set of characters from the specified into the specified byte array. - /// The actual number of bytes written into bytes. - /// The containing the set of characters to encode. - /// The index of the first character to encode. - /// The number of characters to encode. - /// The byte array to contain the resulting sequence of bytes. - /// The index at which to start writing the resulting sequence of bytes. - public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) => - GetBytes(s.ToCharArray(), charIndex, charCount, bytes, byteIndex); - - /// Encodes all the characters in the specified string into a sequence of bytes. - /// A byte array containing the results of encoding the specified set of characters. - /// The string containing the characters to encode. - public override byte[] GetBytes(string s) - { - if(s == null) - throw new ArgumentNullException(nameof(s)); - - return GetBytes(s.ToCharArray(), 0, new StringInfo(s).LengthInTextElements); - } - - /// Encodes a set of characters from the specified character array into the specified byte array. - /// The actual number of bytes written into bytes. - /// The character array containing the set of characters to encode. - /// The index of the first character to encode. - /// The number of characters to encode. - /// The byte array to contain the resulting sequence of bytes. - /// The index at which to start writing the resulting sequence of bytes. - public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - if(bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if(charIndex < 0) - throw new ArgumentOutOfRangeException(nameof(charIndex)); - - if(charCount < 0) - throw new ArgumentOutOfRangeException(nameof(charCount)); - - if(byteIndex < 0) - throw new ArgumentOutOfRangeException(nameof(byteIndex)); - - if(charIndex >= chars.Length) - throw new ArgumentOutOfRangeException(nameof(charIndex)); - - if(charCount + charIndex > chars.Length) - throw new ArgumentOutOfRangeException(nameof(charCount)); - - if(byteIndex >= bytes.Length) - throw new ArgumentOutOfRangeException(nameof(byteIndex)); - - if(byteIndex + charCount > bytes.Length) - throw new ArgumentException(nameof(bytes)); - - byte[] temp = GetBytes(chars, charIndex, charCount); - - for(int i = 0; i < temp.Length; i++) - bytes[i + byteIndex] = temp[i]; - - return charCount; - } - - /// Encodes a set of characters from the specified character array into a sequence of bytes. - /// A byte array containing the results of encoding the specified set of characters. - /// The character array containing the set of characters to encode. - /// The index of the first character to encode. - /// The number of characters to encode. - public override byte[] GetBytes(char[] chars, int index, int count) - { - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - if(index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - - string s = new(chars); - - if(count + index > new StringInfo(s).LengthInTextElements) - throw new ArgumentOutOfRangeException(nameof(count)); - - byte[] bytes = new byte[count]; - - StringRuneEnumerator runes = s.EnumerateRunes(); - runes.MoveNext(); - - for(int i = 0; i < index; i++) - { - if(!runes.MoveNext()) - throw new ArgumentOutOfRangeException(nameof(index)); - } - - bool finished = false; - - for(int i = 0; i < count; i++) - { - if(finished) - throw new ArgumentOutOfRangeException(nameof(count)); - - bytes[i] = GetByte(runes.Current); - - finished = !runes.MoveNext(); - } - - return bytes; - } - - /// Encodes all the characters in the specified character array into a sequence of bytes. - /// A byte array containing the results of encoding the specified set of characters. - /// The character array containing the characters to encode. - public override byte[] GetBytes(char[] chars) => GetBytes(chars, 0, chars.Length); - - /// Calculates the number of characters produced by decoding all the bytes in the specified byte array. - /// The number of characters produced by decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - public override int GetCharCount(byte[] bytes) => GetCharCount(bytes, 0, bytes.Length); - - /// Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array. - /// The number of characters produced by decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - /// The index of the first byte to decode. - /// The number of bytes to decode. - public override int GetCharCount(byte[] bytes, int index, int count) - { - if(bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if(index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - - if(count + index > bytes.Length) - throw new ArgumentOutOfRangeException(nameof(count)); - - return count; - } - - /// Decodes a sequence of bytes from the specified byte array into the specified character array. - /// The actual number of characters written into chars. - /// The byte array containing the sequence of bytes to decode. - /// The index of the first byte to decode. - /// The number of bytes to decode. - /// The character array to contain the resulting set of characters. - /// The index at which to start writing the resulting set of characters. - public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) - { - if(bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if(chars == null) - throw new ArgumentNullException(nameof(chars)); - - if(byteIndex < 0) - throw new ArgumentOutOfRangeException(nameof(byteIndex)); - - if(byteCount < 0) - throw new ArgumentOutOfRangeException(nameof(byteCount)); - - if(charIndex < 0) - throw new ArgumentOutOfRangeException(nameof(charIndex)); - - if(byteIndex >= bytes.Length) - throw new ArgumentOutOfRangeException(nameof(byteIndex)); - - if(byteCount + byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException(nameof(byteCount)); - - if(charIndex >= chars.Length) - throw new ArgumentOutOfRangeException(nameof(charIndex)); - - if(charIndex + byteCount > chars.Length) - throw new ArgumentException(nameof(chars)); - - char[] temp = GetChars(bytes, byteIndex, byteCount); - - for(int i = 0; i < temp.Length; i++) - chars[i + charIndex] = temp[i]; - - return byteCount; - } - - /// Decodes all the bytes in the specified byte array into a set of characters. - /// A character array containing the results of decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - public override char[] GetChars(byte[] bytes) => GetChars(bytes, 0, bytes.Length); - - /// Decodes a sequence of bytes from the specified byte array into a set of characters. - /// The chars. - /// The byte array containing the sequence of bytes to decode. - /// The index of the first byte to decode. - /// The number of bytes to decode. - public override char[] GetChars(byte[] bytes, int index, int count) => - GetString(bytes, index, count).ToCharArray(); - - /// Calculates the maximum number of bytes produced by encoding the specified number of characters. - /// The maximum number of bytes produced by encoding the specified number of characters. - /// The number of characters to encode. - public override int GetMaxByteCount(int charCount) - { - if(charCount < 0) - throw new ArgumentOutOfRangeException(nameof(charCount)); - - return charCount; - } - - /// Calculates the maximum number of characters produced by decoding the specified number of bytes. - /// The maximum number of characters produced by decoding the specified number of bytes. - /// The number of bytes to decode. - public override int GetMaxCharCount(int byteCount) - { - if(byteCount < 0) - throw new ArgumentOutOfRangeException(nameof(byteCount)); - - return byteCount; - } - - /// Returns a sequence of bytes that specifies the encoding used. - /// A byte array of length zero, as a preamble is not required. - public override byte[] GetPreamble() => new byte[0]; - - /// Decodes all the bytes in the specified byte array into a string. - /// A string that contains the results of decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - public override string GetString(byte[] bytes) => GetString(bytes, 0, bytes.Length); - - /// Decodes a sequence of bytes from the specified byte array into a string. - /// A string that contains the results of decoding the specified sequence of bytes. - /// The byte array containing the sequence of bytes to decode. - /// The index of the first byte to decode. - /// The number of bytes to decode. - public override string GetString(byte[] bytes, int index, int count) - { - if(bytes == null) - throw new ArgumentNullException(nameof(bytes)); - - if(index < 0) - throw new ArgumentOutOfRangeException(nameof(index)); - - if(count < 0) - throw new ArgumentOutOfRangeException(nameof(count)); - - if(count + index > bytes.Length) - throw new ArgumentOutOfRangeException(nameof(count)); - - Rune[] runes = new Rune[count]; - - for(int i = 0; i < count; i++) - runes[i] = GetChar(bytes[index + i]); - - char[] chars = new char[runes.Select(r => r.Utf16SequenceLength).Sum()]; - - int outPos = 0; - - foreach(var r in runes) - outPos += r.EncodeToUtf16(new Span(chars, outPos, chars.Length - outPos)); - - return new string(chars); - } - - /// Converts a codepage character to an Unicode character - /// Unicode character. - /// Codepage character. - Rune GetChar(byte character) => CharTable[character]; - - private protected abstract byte GetByte(Rune character); + return new StringInfo(s).LengthInTextElements; } + + /// Calculates the number of bytes produced by encoding a set of characters from the specified character array. + /// The number of bytes produced by encoding the specified characters. + /// The character array containing the set of characters to encode. + /// The index of the first character to encode. + /// The number of characters to encode. + public override int GetByteCount(char[] chars, int index, int count) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + if(index < 0 || + index >= chars.Length) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0 || + index + count > chars.Length) + throw new ArgumentOutOfRangeException(nameof(index)); + + return new StringInfo(new string(chars, index, count)).LengthInTextElements; + } + + /// Calculates the number of bytes produced by encoding all the characters in the specified character array. + /// The number of bytes produced by encoding all the characters in the specified character array. + /// The character array containing the characters to encode. + public override int GetByteCount(char[] chars) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + return new StringInfo(new string(chars)).LengthInTextElements; + } + + /// Encodes a set of characters from the specified into the specified byte array. + /// The actual number of bytes written into bytes. + /// The containing the set of characters to encode. + /// The index of the first character to encode. + /// The number of characters to encode. + /// The byte array to contain the resulting sequence of bytes. + /// The index at which to start writing the resulting sequence of bytes. + public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) => + GetBytes(s.ToCharArray(), charIndex, charCount, bytes, byteIndex); + + /// Encodes all the characters in the specified string into a sequence of bytes. + /// A byte array containing the results of encoding the specified set of characters. + /// The string containing the characters to encode. + public override byte[] GetBytes(string s) + { + if(s == null) + throw new ArgumentNullException(nameof(s)); + + return GetBytes(s.ToCharArray(), 0, new StringInfo(s).LengthInTextElements); + } + + /// Encodes a set of characters from the specified character array into the specified byte array. + /// The actual number of bytes written into bytes. + /// The character array containing the set of characters to encode. + /// The index of the first character to encode. + /// The number of characters to encode. + /// The byte array to contain the resulting sequence of bytes. + /// The index at which to start writing the resulting sequence of bytes. + public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + if(bytes == null) + throw new ArgumentNullException(nameof(bytes)); + + if(charIndex < 0) + throw new ArgumentOutOfRangeException(nameof(charIndex)); + + if(charCount < 0) + throw new ArgumentOutOfRangeException(nameof(charCount)); + + if(byteIndex < 0) + throw new ArgumentOutOfRangeException(nameof(byteIndex)); + + if(charIndex >= chars.Length) + throw new ArgumentOutOfRangeException(nameof(charIndex)); + + if(charCount + charIndex > chars.Length) + throw new ArgumentOutOfRangeException(nameof(charCount)); + + if(byteIndex >= bytes.Length) + throw new ArgumentOutOfRangeException(nameof(byteIndex)); + + if(byteIndex + charCount > bytes.Length) + throw new ArgumentException(nameof(bytes)); + + byte[] temp = GetBytes(chars, charIndex, charCount); + + for(int i = 0; i < temp.Length; i++) + bytes[i + byteIndex] = temp[i]; + + return charCount; + } + + /// Encodes a set of characters from the specified character array into a sequence of bytes. + /// A byte array containing the results of encoding the specified set of characters. + /// The character array containing the set of characters to encode. + /// The index of the first character to encode. + /// The number of characters to encode. + public override byte[] GetBytes(char[] chars, int index, int count) + { + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + if(index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0) + throw new ArgumentOutOfRangeException(nameof(count)); + + string s = new(chars); + + if(count + index > new StringInfo(s).LengthInTextElements) + throw new ArgumentOutOfRangeException(nameof(count)); + + byte[] bytes = new byte[count]; + + StringRuneEnumerator runes = s.EnumerateRunes(); + runes.MoveNext(); + + for(int i = 0; i < index; i++) + { + if(!runes.MoveNext()) + throw new ArgumentOutOfRangeException(nameof(index)); + } + + bool finished = false; + + for(int i = 0; i < count; i++) + { + if(finished) + throw new ArgumentOutOfRangeException(nameof(count)); + + bytes[i] = GetByte(runes.Current); + + finished = !runes.MoveNext(); + } + + return bytes; + } + + /// Encodes all the characters in the specified character array into a sequence of bytes. + /// A byte array containing the results of encoding the specified set of characters. + /// The character array containing the characters to encode. + public override byte[] GetBytes(char[] chars) => GetBytes(chars, 0, chars.Length); + + /// Calculates the number of characters produced by decoding all the bytes in the specified byte array. + /// The number of characters produced by decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + public override int GetCharCount(byte[] bytes) => GetCharCount(bytes, 0, bytes.Length); + + /// Calculates the number of characters produced by decoding a sequence of bytes from the specified byte array. + /// The number of characters produced by decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + /// The index of the first byte to decode. + /// The number of bytes to decode. + public override int GetCharCount(byte[] bytes, int index, int count) + { + if(bytes == null) + throw new ArgumentNullException(nameof(bytes)); + + if(index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0) + throw new ArgumentOutOfRangeException(nameof(count)); + + if(count + index > bytes.Length) + throw new ArgumentOutOfRangeException(nameof(count)); + + return count; + } + + /// Decodes a sequence of bytes from the specified byte array into the specified character array. + /// The actual number of characters written into chars. + /// The byte array containing the sequence of bytes to decode. + /// The index of the first byte to decode. + /// The number of bytes to decode. + /// The character array to contain the resulting set of characters. + /// The index at which to start writing the resulting set of characters. + public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) + { + if(bytes == null) + throw new ArgumentNullException(nameof(bytes)); + + if(chars == null) + throw new ArgumentNullException(nameof(chars)); + + if(byteIndex < 0) + throw new ArgumentOutOfRangeException(nameof(byteIndex)); + + if(byteCount < 0) + throw new ArgumentOutOfRangeException(nameof(byteCount)); + + if(charIndex < 0) + throw new ArgumentOutOfRangeException(nameof(charIndex)); + + if(byteIndex >= bytes.Length) + throw new ArgumentOutOfRangeException(nameof(byteIndex)); + + if(byteCount + byteIndex > bytes.Length) + throw new ArgumentOutOfRangeException(nameof(byteCount)); + + if(charIndex >= chars.Length) + throw new ArgumentOutOfRangeException(nameof(charIndex)); + + if(charIndex + byteCount > chars.Length) + throw new ArgumentException(nameof(chars)); + + char[] temp = GetChars(bytes, byteIndex, byteCount); + + for(int i = 0; i < temp.Length; i++) + chars[i + charIndex] = temp[i]; + + return byteCount; + } + + /// Decodes all the bytes in the specified byte array into a set of characters. + /// A character array containing the results of decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + public override char[] GetChars(byte[] bytes) => GetChars(bytes, 0, bytes.Length); + + /// Decodes a sequence of bytes from the specified byte array into a set of characters. + /// The chars. + /// The byte array containing the sequence of bytes to decode. + /// The index of the first byte to decode. + /// The number of bytes to decode. + public override char[] GetChars(byte[] bytes, int index, int count) => + GetString(bytes, index, count).ToCharArray(); + + /// Calculates the maximum number of bytes produced by encoding the specified number of characters. + /// The maximum number of bytes produced by encoding the specified number of characters. + /// The number of characters to encode. + public override int GetMaxByteCount(int charCount) + { + if(charCount < 0) + throw new ArgumentOutOfRangeException(nameof(charCount)); + + return charCount; + } + + /// Calculates the maximum number of characters produced by decoding the specified number of bytes. + /// The maximum number of characters produced by decoding the specified number of bytes. + /// The number of bytes to decode. + public override int GetMaxCharCount(int byteCount) + { + if(byteCount < 0) + throw new ArgumentOutOfRangeException(nameof(byteCount)); + + return byteCount; + } + + /// Returns a sequence of bytes that specifies the encoding used. + /// A byte array of length zero, as a preamble is not required. + public override byte[] GetPreamble() => new byte[0]; + + /// Decodes all the bytes in the specified byte array into a string. + /// A string that contains the results of decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + public override string GetString(byte[] bytes) => GetString(bytes, 0, bytes.Length); + + /// Decodes a sequence of bytes from the specified byte array into a string. + /// A string that contains the results of decoding the specified sequence of bytes. + /// The byte array containing the sequence of bytes to decode. + /// The index of the first byte to decode. + /// The number of bytes to decode. + public override string GetString(byte[] bytes, int index, int count) + { + if(bytes == null) + throw new ArgumentNullException(nameof(bytes)); + + if(index < 0) + throw new ArgumentOutOfRangeException(nameof(index)); + + if(count < 0) + throw new ArgumentOutOfRangeException(nameof(count)); + + if(count + index > bytes.Length) + throw new ArgumentOutOfRangeException(nameof(count)); + + Rune[] runes = new Rune[count]; + + for(int i = 0; i < count; i++) + runes[i] = GetChar(bytes[index + i]); + + char[] chars = new char[runes.Select(r => r.Utf16SequenceLength).Sum()]; + + int outPos = 0; + + foreach(var r in runes) + outPos += r.EncodeToUtf16(new Span(chars, outPos, chars.Length - outPos)); + + return new string(chars); + } + + /// Converts a codepage character to an Unicode character + /// Unicode character. + /// Codepage character. + Rune GetChar(byte character) => CharTable[character]; + + private protected abstract byte GetByte(Rune character); } \ No newline at end of file diff --git a/Claunia.Encoding/ZX80.cs b/Claunia.Encoding/ZX80.cs index 9032207..1e31fe1 100644 --- a/Claunia.Encoding/ZX80.cs +++ b/Claunia.Encoding/ZX80.cs @@ -26,253 +26,252 @@ using System.Text; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents a ZX80 character encoding of Unicode characters. +public class ZX80 : SingleByteEncodingWithRunes { - /// Represents a ZX80 character encoding of Unicode characters. - public class ZX80 : SingleByteEncodingWithRunes + /// + public override string BodyName => "zx80"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Sinclair ZX80 character set"; + /// + public override string HeaderName => "zx80"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => true; + + /// The ZX80 to Unicode character map. + protected override Rune[] CharTable => new[] { - /// - public override string BodyName => "zx80"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Sinclair ZX80 character set"; - /// - public override string HeaderName => "zx80"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + new Rune(0x0020), new Rune(0x0022), new Rune(0x258C), new Rune(0x2584), new Rune(0x2598), new Rune(0x259D), + new Rune(0x2596), new Rune(0x2597), - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => true; + // 0x08 + new Rune(0x259E), new Rune(0x2592), new Rune(0x1FB8F), new Rune(0x1FB8E), new Rune(0x00A3), + new Rune(0x0024), new Rune(0x003A), new Rune(0x003F), - /// The ZX80 to Unicode character map. - protected override Rune[] CharTable => new[] - { - // 0x00 - new Rune(0x0020), new Rune(0x0022), new Rune(0x258C), new Rune(0x2584), new Rune(0x2598), new Rune(0x259D), - new Rune(0x2596), new Rune(0x2597), + // 0x10 + new Rune(0x0028), new Rune(0x0029), new Rune(0x002D), new Rune(0x002B), new Rune(0x002A), new Rune(0x002F), + new Rune(0x003D), new Rune(0x003E), - // 0x08 - new Rune(0x259E), new Rune(0x2592), new Rune(0x1FB8F), new Rune(0x1FB8E), new Rune(0x00A3), - new Rune(0x0024), new Rune(0x003A), new Rune(0x003F), + // 0x18 + new Rune(0x003C), new Rune(0x003B), new Rune(0x002C), new Rune(0x002E), new Rune(0x0030), new Rune(0x0031), + new Rune(0x0032), new Rune(0x0033), - // 0x10 - new Rune(0x0028), new Rune(0x0029), new Rune(0x002D), new Rune(0x002B), new Rune(0x002A), new Rune(0x002F), - new Rune(0x003D), new Rune(0x003E), + // 0x20 + new Rune(0x0034), new Rune(0x0035), new Rune(0x0036), new Rune(0x0037), new Rune(0x0038), new Rune(0x0039), + new Rune(0x0041), new Rune(0x0042), - // 0x18 - new Rune(0x003C), new Rune(0x003B), new Rune(0x002C), new Rune(0x002E), new Rune(0x0030), new Rune(0x0031), - new Rune(0x0032), new Rune(0x0033), + // 0x28 + new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), new Rune(0x0046), new Rune(0x0047), new Rune(0x0048), + new Rune(0x0049), new Rune(0x004A), - // 0x20 - new Rune(0x0034), new Rune(0x0035), new Rune(0x0036), new Rune(0x0037), new Rune(0x0038), new Rune(0x0039), - new Rune(0x0041), new Rune(0x0042), + // 0x30 + new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), new Rune(0x004E), new Rune(0x004F), new Rune(0x0050), + new Rune(0x0051), new Rune(0x0052), - // 0x28 - new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), new Rune(0x0046), new Rune(0x0047), new Rune(0x0048), - new Rune(0x0049), new Rune(0x004A), + // 0x38 + new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), new Rune(0x0056), new Rune(0x0057), new Rune(0x0058), + new Rune(0x0059), new Rune(0x005A), - // 0x30 - new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), new Rune(0x004E), new Rune(0x004F), new Rune(0x0050), - new Rune(0x0051), new Rune(0x0052), + // 0x40 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x38 - new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), new Rune(0x0056), new Rune(0x0057), new Rune(0x0058), - new Rune(0x0059), new Rune(0x005A), + // 0x48 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x40 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x50 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x48 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x58 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x50 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x60 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x58 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x68 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x60 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x70 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x000D), new Rune(0xFFFD), + new Rune(0x000A), new Rune(0x0008), - // 0x68 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x78 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x70 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x000D), new Rune(0xFFFD), - new Rune(0x000A), new Rune(0x0008), + // 0x80 + new Rune(0x2588), new Rune(0xFFFD), new Rune(0x2590), new Rune(0x2580), new Rune(0x2599), new Rune(0x259C), + new Rune(0x259B), new Rune(0x259A), - // 0x78 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x88 + new Rune(0x2592), new Rune(0x1FB90), new Rune(0x1FB91), new Rune(0x1FB92), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - // 0x80 - new Rune(0x2588), new Rune(0xFFFD), new Rune(0x2590), new Rune(0x2580), new Rune(0x2599), new Rune(0x259C), - new Rune(0x259B), new Rune(0x259A), + // 0x90 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0x88 - new Rune(0x2592), new Rune(0x1FB90), new Rune(0x1FB91), new Rune(0x1FB92), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + // 0x98 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0x90 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xA0 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0x98 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xA8 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0xA0 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xB0 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0xA8 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xB8 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0xB0 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xC0 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xB8 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xC8 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0xC0 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xD0 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xC8 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0xD8 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xD0 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0xE0 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xD8 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0xE8 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xE0 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0xF0 + new Rune(0xFFFF), new Rune(0x0000), new Rune(0x0000), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xE8 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0xF8 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0x0000) + }; - // 0xF0 - new Rune(0xFFFF), new Rune(0x0000), new Rune(0x0000), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), - new Rune(0xFFFF), new Rune(0xFFFF), - - // 0xF8 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0x0000) - }; - - /// Converts a Unicode character to an ZX80 character - /// ZX80 character. - /// Unicode character. - private protected override byte GetByte(Rune character) => character.Value switch - { - 0x0020 => 0x00, - 0x0022 => 0x01, - 0x258C => 0x02, - 0x2584 => 0x03, - 0x2598 => 0x04, - 0x259D => 0x05, - 0x2596 => 0x06, - 0x2597 => 0x07, - 0x259E => 0x08, - 0x2592 => 0x09, - 0x1FB8F => 0x0A, - 0x1FB8E => 0x0B, - 0x00A3 => 0x0C, - 0x0024 => 0x0D, - 0x003A => 0x0E, - 0x003F => 0x0F, - 0x0028 => 0x10, - 0x0029 => 0x11, - 0x002D => 0x12, - 0x002B => 0x13, - 0x002A => 0x14, - 0x002F => 0x15, - 0x003D => 0x16, - 0x003E => 0x17, - 0x003C => 0x18, - 0x003B => 0x19, - 0x002C => 0x1A, - 0x002E => 0x1B, - 0x0030 => 0x1C, - 0x0031 => 0x1D, - 0x0032 => 0x1E, - 0x0033 => 0x1F, - 0x0034 => 0x20, - 0x0035 => 0x21, - 0x0036 => 0x22, - 0x0037 => 0x23, - 0x0038 => 0x24, - 0x0039 => 0x25, - 0x0041 => 0x26, - 0x0042 => 0x27, - 0x0043 => 0x28, - 0x0044 => 0x29, - 0x0045 => 0x2A, - 0x0046 => 0x2B, - 0x0047 => 0x2C, - 0x0048 => 0x2D, - 0x0049 => 0x2E, - 0x004A => 0x2F, - 0x004B => 0x30, - 0x004C => 0x31, - 0x004D => 0x32, - 0x004E => 0x33, - 0x004F => 0x34, - 0x0050 => 0x35, - 0x0051 => 0x36, - 0x0052 => 0x37, - 0x0053 => 0x38, - 0x0054 => 0x39, - 0x0055 => 0x3A, - 0x0056 => 0x3B, - 0x0057 => 0x3C, - 0x0058 => 0x3D, - 0x0059 => 0x3E, - 0x005A => 0x3F, - 0x000D => 0x74, - 0x000A => 0x76, - 0x0008 => 0x77, - 0x2588 => 0x80, - 0x2590 => 0x82, - 0x2580 => 0x83, - 0x259F => 0x84, - 0x2599 => 0x85, - 0x259C => 0x86, - 0x259B => 0x87, - 0x259A => 0x88, - 0x1FB90 => 0x89, - 0x1FB91 => 0x8A, - 0x1FB92 => 0x8B, - _ => 0x0F - }; - } + /// Converts a Unicode character to an ZX80 character + /// ZX80 character. + /// Unicode character. + private protected override byte GetByte(Rune character) => character.Value switch + { + 0x0020 => 0x00, + 0x0022 => 0x01, + 0x258C => 0x02, + 0x2584 => 0x03, + 0x2598 => 0x04, + 0x259D => 0x05, + 0x2596 => 0x06, + 0x2597 => 0x07, + 0x259E => 0x08, + 0x2592 => 0x09, + 0x1FB8F => 0x0A, + 0x1FB8E => 0x0B, + 0x00A3 => 0x0C, + 0x0024 => 0x0D, + 0x003A => 0x0E, + 0x003F => 0x0F, + 0x0028 => 0x10, + 0x0029 => 0x11, + 0x002D => 0x12, + 0x002B => 0x13, + 0x002A => 0x14, + 0x002F => 0x15, + 0x003D => 0x16, + 0x003E => 0x17, + 0x003C => 0x18, + 0x003B => 0x19, + 0x002C => 0x1A, + 0x002E => 0x1B, + 0x0030 => 0x1C, + 0x0031 => 0x1D, + 0x0032 => 0x1E, + 0x0033 => 0x1F, + 0x0034 => 0x20, + 0x0035 => 0x21, + 0x0036 => 0x22, + 0x0037 => 0x23, + 0x0038 => 0x24, + 0x0039 => 0x25, + 0x0041 => 0x26, + 0x0042 => 0x27, + 0x0043 => 0x28, + 0x0044 => 0x29, + 0x0045 => 0x2A, + 0x0046 => 0x2B, + 0x0047 => 0x2C, + 0x0048 => 0x2D, + 0x0049 => 0x2E, + 0x004A => 0x2F, + 0x004B => 0x30, + 0x004C => 0x31, + 0x004D => 0x32, + 0x004E => 0x33, + 0x004F => 0x34, + 0x0050 => 0x35, + 0x0051 => 0x36, + 0x0052 => 0x37, + 0x0053 => 0x38, + 0x0054 => 0x39, + 0x0055 => 0x3A, + 0x0056 => 0x3B, + 0x0057 => 0x3C, + 0x0058 => 0x3D, + 0x0059 => 0x3E, + 0x005A => 0x3F, + 0x000D => 0x74, + 0x000A => 0x76, + 0x0008 => 0x77, + 0x2588 => 0x80, + 0x2590 => 0x82, + 0x2580 => 0x83, + 0x259F => 0x84, + 0x2599 => 0x85, + 0x259C => 0x86, + 0x259B => 0x87, + 0x259A => 0x88, + 0x1FB90 => 0x89, + 0x1FB91 => 0x8A, + 0x1FB92 => 0x8B, + _ => 0x0F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/ZX81.cs b/Claunia.Encoding/ZX81.cs index 492293c..747c50a 100644 --- a/Claunia.Encoding/ZX81.cs +++ b/Claunia.Encoding/ZX81.cs @@ -26,253 +26,252 @@ using System.Text; -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents a ZX81 character encoding of Unicode characters. +public class ZX81 : SingleByteEncodingWithRunes { - /// Represents a ZX81 character encoding of Unicode characters. - public class ZX81 : SingleByteEncodingWithRunes + /// + public override string BodyName => "zx81"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Sinclair ZX81 character set"; + /// + public override string HeaderName => "zx81"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => true; + + /// The ZX81 to Unicode character map. + protected override Rune[] CharTable => new[] { - /// - public override string BodyName => "zx81"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Sinclair ZX81 character set"; - /// - public override string HeaderName => "zx81"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + new Rune(0x0020), new Rune(0x2598), new Rune(0x259D), new Rune(0x2580), new Rune(0x2596), new Rune(0x258C), + new Rune(0x259E), new Rune(0x259B), - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => true; + // 0x08 + new Rune(0x2592), new Rune(0x1FB8F), new Rune(0x1FB8E), new Rune(0x0022), new Rune(0x00A3), + new Rune(0x0024), new Rune(0x003A), new Rune(0x003F), - /// The ZX81 to Unicode character map. - protected override Rune[] CharTable => new[] - { - // 0x00 - new Rune(0x0020), new Rune(0x2598), new Rune(0x259D), new Rune(0x2580), new Rune(0x2596), new Rune(0x258C), - new Rune(0x259E), new Rune(0x259B), + // 0x10 + new Rune(0x0028), new Rune(0x0029), new Rune(0x003E), new Rune(0x003C), new Rune(0x003D), new Rune(0x002B), + new Rune(0x002D), new Rune(0x002A), - // 0x08 - new Rune(0x2592), new Rune(0x1FB8F), new Rune(0x1FB8E), new Rune(0x0022), new Rune(0x00A3), - new Rune(0x0024), new Rune(0x003A), new Rune(0x003F), + // 0x18 + new Rune(0x002F), new Rune(0x003B), new Rune(0x002C), new Rune(0x002E), new Rune(0x0030), new Rune(0x0031), + new Rune(0x0032), new Rune(0x0033), - // 0x10 - new Rune(0x0028), new Rune(0x0029), new Rune(0x003E), new Rune(0x003C), new Rune(0x003D), new Rune(0x002B), - new Rune(0x002D), new Rune(0x002A), + // 0x20 + new Rune(0x0034), new Rune(0x0035), new Rune(0x0036), new Rune(0x0037), new Rune(0x0038), new Rune(0x0039), + new Rune(0x0041), new Rune(0x0042), - // 0x18 - new Rune(0x002F), new Rune(0x003B), new Rune(0x002C), new Rune(0x002E), new Rune(0x0030), new Rune(0x0031), - new Rune(0x0032), new Rune(0x0033), + // 0x28 + new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), new Rune(0x0046), new Rune(0x0047), new Rune(0x0048), + new Rune(0x0049), new Rune(0x004A), - // 0x20 - new Rune(0x0034), new Rune(0x0035), new Rune(0x0036), new Rune(0x0037), new Rune(0x0038), new Rune(0x0039), - new Rune(0x0041), new Rune(0x0042), + // 0x30 + new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), new Rune(0x004E), new Rune(0x004F), new Rune(0x0050), + new Rune(0x0051), new Rune(0x0052), - // 0x28 - new Rune(0x0043), new Rune(0x0044), new Rune(0x0045), new Rune(0x0046), new Rune(0x0047), new Rune(0x0048), - new Rune(0x0049), new Rune(0x004A), + // 0x38 + new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), new Rune(0x0056), new Rune(0x0057), new Rune(0x0058), + new Rune(0x0059), new Rune(0x005A), - // 0x30 - new Rune(0x004B), new Rune(0x004C), new Rune(0x004D), new Rune(0x004E), new Rune(0x004F), new Rune(0x0050), - new Rune(0x0051), new Rune(0x0052), + // 0x40 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x38 - new Rune(0x0053), new Rune(0x0054), new Rune(0x0055), new Rune(0x0056), new Rune(0x0057), new Rune(0x0058), - new Rune(0x0059), new Rune(0x005A), + // 0x48 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x40 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x50 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x48 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x58 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x50 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x60 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x58 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x68 + new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0x0000), new Rune(0x0000), - // 0x60 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x70 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0x000A), new Rune(0x0008), - // 0x68 - new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0x0000), new Rune(0x0000), + // 0x78 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0x70 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0x000A), new Rune(0x0008), + // 0x80 + new Rune(0x2588), new Rune(0x259F), new Rune(0x2599), new Rune(0x2584), new Rune(0x259C), new Rune(0x2590), + new Rune(0x259A), new Rune(0x2597), - // 0x78 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), new Rune(0x0000), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0x88 + new Rune(0x1FB90), new Rune(0x1FB91), new Rune(0x1FB92), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - // 0x80 - new Rune(0x2588), new Rune(0x259F), new Rune(0x2599), new Rune(0x2584), new Rune(0x259C), new Rune(0x2590), - new Rune(0x259A), new Rune(0x2597), + // 0x90 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0x88 - new Rune(0x1FB90), new Rune(0x1FB91), new Rune(0x1FB92), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + // 0x98 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0x90 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xA0 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0x98 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xA8 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0xA0 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xB0 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0xA8 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xB8 + new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), + new Rune(0xFFFD), new Rune(0xFFFD), - // 0xB0 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xC0 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xB8 - new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), new Rune(0xFFFD), - new Rune(0xFFFD), new Rune(0xFFFD), + // 0xC8 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xC0 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0x0000), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0xD0 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xC8 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0xD8 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xD0 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0xE0 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xD8 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0xE8 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xE0 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0xF0 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF), - // 0xE8 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), + // 0xF8 + new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), + new Rune(0xFFFF), new Rune(0xFFFF) + }; - // 0xF0 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF), - - // 0xF8 - new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), new Rune(0xFFFF), - new Rune(0xFFFF), new Rune(0xFFFF) - }; - - /// Converts a Unicode character to an ZX81 character - /// ZX81 character. - /// Unicode character. - private protected override byte GetByte(Rune character) => character.Value switch - { - 0x0020 => 0x00, - 0x2598 => 0x01, - 0x259D => 0x02, - 0x2580 => 0x03, - 0x2596 => 0x04, - 0x258C => 0x05, - 0x259E => 0x06, - 0x259B => 0x07, - 0x2592 => 0x08, - 0x1FB8F => 0x09, - 0x1FB8E => 0x0A, - 0x0022 => 0x0B, - 0x00A3 => 0x0C, - 0x0024 => 0x0D, - 0x003A => 0x0E, - 0x003F => 0x0F, - 0x0028 => 0x10, - 0x0029 => 0x11, - 0x003E => 0x12, - 0x003C => 0x13, - 0x003D => 0x14, - 0x002B => 0x15, - 0x002D => 0x16, - 0x002A => 0x17, - 0x002F => 0x18, - 0x003B => 0x19, - 0x002C => 0x1A, - 0x002E => 0x1B, - 0x0030 => 0x1C, - 0x0031 => 0x1D, - 0x0032 => 0x1E, - 0x0033 => 0x1F, - 0x0034 => 0x20, - 0x0035 => 0x21, - 0x0036 => 0x22, - 0x0037 => 0x23, - 0x0038 => 0x24, - 0x0039 => 0x25, - 0x0041 => 0x26, - 0x0042 => 0x27, - 0x0043 => 0x28, - 0x0044 => 0x29, - 0x0045 => 0x2A, - 0x0046 => 0x2B, - 0x0047 => 0x2C, - 0x0048 => 0x2D, - 0x0049 => 0x2E, - 0x004A => 0x2F, - 0x004B => 0x30, - 0x004C => 0x31, - 0x004D => 0x32, - 0x004E => 0x33, - 0x004F => 0x34, - 0x0050 => 0x35, - 0x0051 => 0x36, - 0x0052 => 0x37, - 0x0053 => 0x38, - 0x0054 => 0x39, - 0x0055 => 0x3A, - 0x0056 => 0x3B, - 0x0057 => 0x3C, - 0x0058 => 0x3D, - 0x0059 => 0x3E, - 0x005A => 0x3F, - 0x000D => 0x74, - 0x000A => 0x76, - 0x0008 => 0x77, - 0x2588 => 0x80, - 0x259F => 0x81, - 0x2599 => 0x82, - 0x2584 => 0x83, - 0x259C => 0x84, - 0x2590 => 0x85, - 0x259A => 0x86, - 0x2597 => 0x87, - 0x1FB90 => 0x88, - 0x1FB91 => 0x89, - 0x1FB92 => 0x8A, - _ => 0x0F - }; - } + /// Converts a Unicode character to an ZX81 character + /// ZX81 character. + /// Unicode character. + private protected override byte GetByte(Rune character) => character.Value switch + { + 0x0020 => 0x00, + 0x2598 => 0x01, + 0x259D => 0x02, + 0x2580 => 0x03, + 0x2596 => 0x04, + 0x258C => 0x05, + 0x259E => 0x06, + 0x259B => 0x07, + 0x2592 => 0x08, + 0x1FB8F => 0x09, + 0x1FB8E => 0x0A, + 0x0022 => 0x0B, + 0x00A3 => 0x0C, + 0x0024 => 0x0D, + 0x003A => 0x0E, + 0x003F => 0x0F, + 0x0028 => 0x10, + 0x0029 => 0x11, + 0x003E => 0x12, + 0x003C => 0x13, + 0x003D => 0x14, + 0x002B => 0x15, + 0x002D => 0x16, + 0x002A => 0x17, + 0x002F => 0x18, + 0x003B => 0x19, + 0x002C => 0x1A, + 0x002E => 0x1B, + 0x0030 => 0x1C, + 0x0031 => 0x1D, + 0x0032 => 0x1E, + 0x0033 => 0x1F, + 0x0034 => 0x20, + 0x0035 => 0x21, + 0x0036 => 0x22, + 0x0037 => 0x23, + 0x0038 => 0x24, + 0x0039 => 0x25, + 0x0041 => 0x26, + 0x0042 => 0x27, + 0x0043 => 0x28, + 0x0044 => 0x29, + 0x0045 => 0x2A, + 0x0046 => 0x2B, + 0x0047 => 0x2C, + 0x0048 => 0x2D, + 0x0049 => 0x2E, + 0x004A => 0x2F, + 0x004B => 0x30, + 0x004C => 0x31, + 0x004D => 0x32, + 0x004E => 0x33, + 0x004F => 0x34, + 0x0050 => 0x35, + 0x0051 => 0x36, + 0x0052 => 0x37, + 0x0053 => 0x38, + 0x0054 => 0x39, + 0x0055 => 0x3A, + 0x0056 => 0x3B, + 0x0057 => 0x3C, + 0x0058 => 0x3D, + 0x0059 => 0x3E, + 0x005A => 0x3F, + 0x000D => 0x74, + 0x000A => 0x76, + 0x0008 => 0x77, + 0x2588 => 0x80, + 0x259F => 0x81, + 0x2599 => 0x82, + 0x2584 => 0x83, + 0x259C => 0x84, + 0x2590 => 0x85, + 0x259A => 0x86, + 0x2597 => 0x87, + 0x1FB90 => 0x88, + 0x1FB91 => 0x89, + 0x1FB92 => 0x8A, + _ => 0x0F + }; } \ No newline at end of file diff --git a/Claunia.Encoding/ZXSpectrum.cs b/Claunia.Encoding/ZXSpectrum.cs index e252b58..9d3811a 100644 --- a/Claunia.Encoding/ZXSpectrum.cs +++ b/Claunia.Encoding/ZXSpectrum.cs @@ -24,256 +24,255 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -namespace Claunia.Encoding +namespace Claunia.Encoding; + +/// Represents an ZX Spectrum character encoding of Unicode characters. +public class ZXSpectrum : SingleByteEncoding { - /// Represents an ZX Spectrum character encoding of Unicode characters. - public class ZXSpectrum : SingleByteEncoding + /// + public override string BodyName => "spectrum"; + /// + public override int CodePage => 0; + /// + public override string EncodingName => "Sinclair ZX Spectrum character set"; + /// + public override string HeaderName => "spectrum"; + /// + public override string WebName => ""; + /// + public override int WindowsCodePage => 0; + + /// + public override bool IsBrowserDisplay => false; + /// + public override bool IsBrowserSave => false; + /// + public override bool IsMailNewsDisplay => false; + /// + public override bool IsMailNewsSave => false; + /// + public override bool IsReadOnly => false; + /// + public override bool IsSingleByte => true; + + /// The ZX Spectrum to Unicode character map. + protected override char[] CharTable => new[] { - /// - public override string BodyName => "spectrum"; - /// - public override int CodePage => 0; - /// - public override string EncodingName => "Sinclair ZX Spectrum character set"; - /// - public override string HeaderName => "spectrum"; - /// - public override string WebName => ""; - /// - public override int WindowsCodePage => 0; + // 0x00 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0009', '\u0000', - /// - public override bool IsBrowserDisplay => false; - /// - public override bool IsBrowserSave => false; - /// - public override bool IsMailNewsDisplay => false; - /// - public override bool IsMailNewsSave => false; - /// - public override bool IsReadOnly => false; - /// - public override bool IsSingleByte => true; + // 0x08 + '\uFFFF', '\uFFFF', '\u0000', '\u0000', '\u0000', '\u000D', '\uFFFF', '\u0000', - /// The ZX Spectrum to Unicode character map. - protected override char[] CharTable => new[] - { - // 0x00 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0009', '\u0000', + // 0x10 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u0009', - // 0x08 - '\uFFFF', '\uFFFF', '\u0000', '\u0000', '\u0000', '\u000D', '\uFFFF', '\u0000', + // 0x18 + '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', - // 0x10 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u0009', + // 0x20 + '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', - // 0x18 - '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', + // 0x28 + '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', - // 0x20 - '\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', + // 0x30 + '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - // 0x28 - '\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', + // 0x38 + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', - // 0x30 - '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + // 0x40 + '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', - // 0x38 - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F', + // 0x48 + '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', - // 0x40 - '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047', + // 0x50 + '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', - // 0x48 - '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F', + // 0x58 + '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u2191', '\u005F', - // 0x50 - '\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057', + // 0x60 + '\u00A3', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', - // 0x58 - '\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u2191', '\u005F', + // 0x68 + '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - // 0x60 - '\u00A3', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', + // 0x70 + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', - // 0x68 - '\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + // 0x78 + '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u00A9', - // 0x70 - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077', + // 0x80 + '\u0020', '\u259D', '\u2598', '\u2580', '\u2597', '\u2590', '\u259A', '\u259C', - // 0x78 - '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u00A9', + // 0x88 + '\u2596', '\u259E', '\u258C', '\u259B', '\u2584', '\u259F', '\u2599', '\u2588', - // 0x80 - '\u0020', '\u259D', '\u2598', '\u2580', '\u2597', '\u2590', '\u259A', '\u259C', + // 0x90 + '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', - // 0x88 - '\u2596', '\u259E', '\u258C', '\u259B', '\u2584', '\u259F', '\u2599', '\u2588', + // 0x98 + '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', - // 0x90 - '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', + // 0xA0 + '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFF', '\uFFFF', '\uFFFF', - // 0x98 - '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', + // 0xA8 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - // 0xA0 - '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFF', '\uFFFF', '\uFFFF', + // 0xB0 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - // 0xA8 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', + // 0xB8 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - // 0xB0 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', + // 0xC0 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - // 0xB8 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', + // 0xC8 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - // 0xC0 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', + // 0xD0 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - // 0xC8 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', + // 0xD8 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - // 0xD0 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', + // 0xE0 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - // 0xD8 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', + // 0xE8 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - // 0xE0 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', + // 0xF0 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - // 0xE8 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', + // 0xF8 + '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF' + }; - // 0xF0 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', - - // 0xF8 - '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF' - }; - - /// Converts a Unicode character to an ZX Spectrum character - /// ZX Spectrum character. - /// Unicode character. - private protected override byte GetByte(char character) => character switch - { - '\u0009' => 0x06, - '\u000D' => 0x0D, - '\u0020' => 0x20, - '\u0021' => 0x21, - '\u0022' => 0x22, - '\u0023' => 0x23, - '\u0024' => 0x24, - '\u0025' => 0x25, - '\u0026' => 0x26, - '\u0027' => 0x27, - '\u0028' => 0x28, - '\u0029' => 0x29, - '\u002A' => 0x2A, - '\u002B' => 0x2B, - '\u002C' => 0x2C, - '\u002D' => 0x2D, - '\u002E' => 0x2E, - '\u002F' => 0x2F, - '\u0030' => 0x30, - '\u0031' => 0x31, - '\u0032' => 0x32, - '\u0033' => 0x33, - '\u0034' => 0x34, - '\u0035' => 0x35, - '\u0036' => 0x36, - '\u0037' => 0x37, - '\u0038' => 0x38, - '\u0039' => 0x39, - '\u003A' => 0x3A, - '\u003B' => 0x3B, - '\u003C' => 0x3C, - '\u003D' => 0x3D, - '\u003E' => 0x3E, - '\u003F' => 0x3F, - '\u0040' => 0x40, - '\u0041' => 0x41, - '\u0042' => 0x42, - '\u0043' => 0x43, - '\u0044' => 0x44, - '\u0045' => 0x45, - '\u0046' => 0x46, - '\u0047' => 0x47, - '\u0048' => 0x48, - '\u0049' => 0x49, - '\u004A' => 0x4A, - '\u004B' => 0x4B, - '\u004C' => 0x4C, - '\u004D' => 0x4D, - '\u004E' => 0x4E, - '\u004F' => 0x4F, - '\u0050' => 0x50, - '\u0051' => 0x51, - '\u0052' => 0x52, - '\u0053' => 0x53, - '\u0054' => 0x54, - '\u0055' => 0x55, - '\u0056' => 0x56, - '\u0057' => 0x57, - '\u0058' => 0x58, - '\u0059' => 0x59, - '\u005A' => 0x5A, - '\u005B' => 0x5B, - '\u005C' => 0x5C, - '\u005D' => 0x5D, - '\u2191' => 0x5E, - '\u005F' => 0x5F, - '\u00A3' => 0x60, - '\u0061' => 0x61, - '\u0062' => 0x62, - '\u0063' => 0x63, - '\u0064' => 0x64, - '\u0065' => 0x65, - '\u0066' => 0x66, - '\u0067' => 0x67, - '\u0068' => 0x68, - '\u0069' => 0x69, - '\u006A' => 0x6A, - '\u006B' => 0x6B, - '\u006C' => 0x6C, - '\u006D' => 0x6D, - '\u006E' => 0x6E, - '\u006F' => 0x6F, - '\u0070' => 0x70, - '\u0071' => 0x71, - '\u0072' => 0x72, - '\u0073' => 0x73, - '\u0074' => 0x74, - '\u0075' => 0x75, - '\u0076' => 0x76, - '\u0077' => 0x77, - '\u0078' => 0x78, - '\u0079' => 0x79, - '\u007A' => 0x7A, - '\u007B' => 0x7B, - '\u007C' => 0x7C, - '\u007D' => 0x7D, - '\u007E' => 0x7E, - '\u00A9' => 0x7F, - '\u259D' => 0x81, - '\u2598' => 0x82, - '\u2580' => 0x83, - '\u2597' => 0x84, - '\u2590' => 0x85, - '\u259A' => 0x86, - '\u259C' => 0x87, - '\u2596' => 0x88, - '\u259E' => 0x89, - '\u258C' => 0x8A, - '\u259B' => 0x8B, - '\u2584' => 0x8C, - '\u259F' => 0x8D, - '\u2599' => 0x8E, - '\u2588' => 0x8F, - _ => 0x3F - }; - } + /// Converts a Unicode character to an ZX Spectrum character + /// ZX Spectrum character. + /// Unicode character. + private protected override byte GetByte(char character) => character switch + { + '\u0009' => 0x06, + '\u000D' => 0x0D, + '\u0020' => 0x20, + '\u0021' => 0x21, + '\u0022' => 0x22, + '\u0023' => 0x23, + '\u0024' => 0x24, + '\u0025' => 0x25, + '\u0026' => 0x26, + '\u0027' => 0x27, + '\u0028' => 0x28, + '\u0029' => 0x29, + '\u002A' => 0x2A, + '\u002B' => 0x2B, + '\u002C' => 0x2C, + '\u002D' => 0x2D, + '\u002E' => 0x2E, + '\u002F' => 0x2F, + '\u0030' => 0x30, + '\u0031' => 0x31, + '\u0032' => 0x32, + '\u0033' => 0x33, + '\u0034' => 0x34, + '\u0035' => 0x35, + '\u0036' => 0x36, + '\u0037' => 0x37, + '\u0038' => 0x38, + '\u0039' => 0x39, + '\u003A' => 0x3A, + '\u003B' => 0x3B, + '\u003C' => 0x3C, + '\u003D' => 0x3D, + '\u003E' => 0x3E, + '\u003F' => 0x3F, + '\u0040' => 0x40, + '\u0041' => 0x41, + '\u0042' => 0x42, + '\u0043' => 0x43, + '\u0044' => 0x44, + '\u0045' => 0x45, + '\u0046' => 0x46, + '\u0047' => 0x47, + '\u0048' => 0x48, + '\u0049' => 0x49, + '\u004A' => 0x4A, + '\u004B' => 0x4B, + '\u004C' => 0x4C, + '\u004D' => 0x4D, + '\u004E' => 0x4E, + '\u004F' => 0x4F, + '\u0050' => 0x50, + '\u0051' => 0x51, + '\u0052' => 0x52, + '\u0053' => 0x53, + '\u0054' => 0x54, + '\u0055' => 0x55, + '\u0056' => 0x56, + '\u0057' => 0x57, + '\u0058' => 0x58, + '\u0059' => 0x59, + '\u005A' => 0x5A, + '\u005B' => 0x5B, + '\u005C' => 0x5C, + '\u005D' => 0x5D, + '\u2191' => 0x5E, + '\u005F' => 0x5F, + '\u00A3' => 0x60, + '\u0061' => 0x61, + '\u0062' => 0x62, + '\u0063' => 0x63, + '\u0064' => 0x64, + '\u0065' => 0x65, + '\u0066' => 0x66, + '\u0067' => 0x67, + '\u0068' => 0x68, + '\u0069' => 0x69, + '\u006A' => 0x6A, + '\u006B' => 0x6B, + '\u006C' => 0x6C, + '\u006D' => 0x6D, + '\u006E' => 0x6E, + '\u006F' => 0x6F, + '\u0070' => 0x70, + '\u0071' => 0x71, + '\u0072' => 0x72, + '\u0073' => 0x73, + '\u0074' => 0x74, + '\u0075' => 0x75, + '\u0076' => 0x76, + '\u0077' => 0x77, + '\u0078' => 0x78, + '\u0079' => 0x79, + '\u007A' => 0x7A, + '\u007B' => 0x7B, + '\u007C' => 0x7C, + '\u007D' => 0x7D, + '\u007E' => 0x7E, + '\u00A9' => 0x7F, + '\u259D' => 0x81, + '\u2598' => 0x82, + '\u2580' => 0x83, + '\u2597' => 0x84, + '\u2590' => 0x85, + '\u259A' => 0x86, + '\u259C' => 0x87, + '\u2596' => 0x88, + '\u259E' => 0x89, + '\u258C' => 0x8A, + '\u259B' => 0x8B, + '\u2584' => 0x8C, + '\u259F' => 0x8D, + '\u2599' => 0x8E, + '\u2588' => 0x8F, + _ => 0x3F + }; } \ No newline at end of file