diff --git a/Claunia.Encoding.Tests/ATASCII.cs b/Claunia.Encoding.Tests/ATASCII.cs
index 2c0b1ea..88257aa 100644
--- a/Claunia.Encoding.Tests/ATASCII.cs
+++ b/Claunia.Encoding.Tests/ATASCII.cs
@@ -29,39 +29,48 @@ using NUnit.Framework;
namespace Claunia.Encoding.Tests
{
[TestFixture]
- public class ATASCII
+ 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
+ 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 UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- readonly byte[] UpperLatinBytes =
+ const string DIGITS = "0123456789";
+ readonly byte[] _digitsBytes =
{
- 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
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
};
- const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
- readonly byte[] LowerLatinBytes =
+ const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ readonly byte[] _upperLatinBytes =
{
- 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
+ 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 =
+ 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
+ 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 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()
@@ -69,9 +78,9 @@ namespace Claunia.Encoding.Tests
byte[] byteArray;
string testString;
- byteArray = Encoding.AtariEncoding.GetBytes(Pangrams.English);
+ byteArray = Encoding.AtariEncoding.GetBytes(Pangrams.ENGLISH);
testString = Encoding.AtariEncoding.GetString(byteArray);
- Assert.AreEqual(Pangrams.English, testString);
+ Assert.AreEqual(Pangrams.ENGLISH, testString);
}
[Test]
@@ -79,21 +88,21 @@ namespace Claunia.Encoding.Tests
{
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(UpperLatin, testString);
- testString = Encoding.AtariEncoding.GetString(LowerLatinBytes);
- Assert.AreEqual(LowerLatin, 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]
@@ -101,21 +110,21 @@ namespace Claunia.Encoding.Tests
{
byte[] byteArray;
- byteArray = Encoding.AtariEncoding.GetBytes(Punctuations);
- Assert.AreEqual(PunctuationsBytes, byteArray);
- byteArray = Encoding.AtariEncoding.GetBytes(Digits);
- Assert.AreEqual(DigitsBytes, byteArray);
- byteArray = Encoding.AtariEncoding.GetBytes(UpperLatin);
- Assert.AreEqual(UpperLatinBytes, byteArray);
- byteArray = Encoding.AtariEncoding.GetBytes(LowerLatin);
- 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 791a033..03c3dee 100644
--- a/Claunia.Encoding.Tests/AtariST.cs
+++ b/Claunia.Encoding.Tests/AtariST.cs
@@ -29,203 +29,230 @@ using NUnit.Framework;
namespace Claunia.Encoding.Tests
{
[TestFixture]
- public class AtariST
+ 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
+ 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 UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- readonly byte[] UpperLatinBytes =
+ const string DIGITS = "0123456789";
+ readonly byte[] _digitsBytes =
{
- 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
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
};
- const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
- readonly byte[] LowerLatinBytes =
+ const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ readonly byte[] _upperLatinBytes =
{
- 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
+ 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 =
+ const string SPANISH = "¡¿áéíóúüñÉÜÑ";
+ readonly byte[] _spanishBytes =
{
- 0x82, 0x90, 0x85, 0x8A, 0x97, 0xB6, 0x83, 0x88, 0x8C, 0x93, 0x96, 0x89, 0x8B, 0x81, 0x98, 0x87, 0x80,
- 0xB4, 0xB5, 0x91, 0x92
+ 0xAD, 0xA8, 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x81, 0xA4, 0x90, 0x9A, 0xA5
};
- 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 =
+ 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 =
+ const string DUTCH = "ijIJ";
+ readonly byte[] _dutchBytes =
{
- 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
+ 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 Greek = "αβΓπΣσµτΦΘΩδ¯";
- readonly byte[] GreekBytes = {0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xFF};
- const string Typographic = "ªº«»¨´†¶©®™§°∙·";
- readonly byte[] TypographicBytes =
+ 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 =
+ const string CURRENCY = "¢£¥ƒ";
+ readonly byte[] _currencyBytes =
{
- 0xA9, 0xAA, 0xAB, 0xAC, 0xDE, 0xDF, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6,
- 0xF7, 0xFB, 0xFC, 0xFD, 0xFE
+ 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 Symbols = "⇧⇩⇨⇦❎✓♪ə";
- readonly byte[] SymbolsBytes = {0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x0B, 0x1A};
[Test]
- public void AtariSTPangrams()
+ 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()
+ 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(UpperLatin, testString);
- testString = Encoding.AtariSTEncoding.GetString(LowerLatinBytes);
- Assert.AreEqual(LowerLatin, 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);
- 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);*/
}
+
// TODO: 0x09 => U+1F552, 0x0A => U+1F514
/*const string SymbolsUnicode32 = "\ud83d\udd52\ud83d\udd14";
readonly byte[] SymbolsUnicode32Bytes = { 0x09, 0x0A };*/
[Test]
- public void UnicodeToAtariST()
+ public void UnicodeToAtariSt()
{
byte[] byteArray;
- byteArray = Encoding.AtariSTEncoding.GetBytes(Punctuations);
- Assert.AreEqual(PunctuationsBytes, byteArray);
- byteArray = Encoding.AtariSTEncoding.GetBytes(Digits);
- Assert.AreEqual(DigitsBytes, byteArray);
- byteArray = Encoding.AtariSTEncoding.GetBytes(UpperLatin);
- Assert.AreEqual(UpperLatinBytes, byteArray);
- byteArray = Encoding.AtariSTEncoding.GetBytes(LowerLatin);
- Assert.AreEqual(LowerLatinBytes, 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(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(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(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(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);*/
diff --git a/Claunia.Encoding.Tests/GetEncs.cs b/Claunia.Encoding.Tests/GetEncs.cs
index 80e10f3..84e73e9 100644
--- a/Claunia.Encoding.Tests/GetEncs.cs
+++ b/Claunia.Encoding.Tests/GetEncs.cs
@@ -33,6 +33,7 @@ namespace Claunia.Encoding.Tests
public class GetEncs
{
[Test]
+
// Well basically this is taken from MSDN's documentation :p
public void GetAllEncs()
{
@@ -47,14 +48,15 @@ namespace Claunia.Encoding.Tests
{
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.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()
{
@@ -62,6 +64,7 @@ namespace Claunia.Encoding.Tests
}
[Test]
+
// Well basically this is taken from MSDN's documentation :p
public void GetInternalEncoding()
{
diff --git a/Claunia.Encoding.Tests/LisaRoman.cs b/Claunia.Encoding.Tests/LisaRoman.cs
index f848d7a..236c6ab 100644
--- a/Claunia.Encoding.Tests/LisaRoman.cs
+++ b/Claunia.Encoding.Tests/LisaRoman.cs
@@ -31,58 +31,73 @@ namespace Claunia.Encoding.Tests
[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
+ 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 UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- readonly byte[] UpperLatinBytes =
+ const string DIGITS = "0123456789";
+ readonly byte[] _digitsBytes =
{
- 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
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
};
- const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
- readonly byte[] LowerLatinBytes =
+ const string UPPER_LATIN = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ readonly byte[] _upperLatinBytes =
{
- 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
+ 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 =
+ const string SPANISH = "¡¿áéíóúüñÉÜÑ";
+ readonly byte[] _spanishBytes =
{
- 0x8E, 0x83, 0x88, 0x8F, 0x9D, 0xCB, 0x89, 0x90, 0x94, 0x99, 0x9E, 0x91, 0x95, 0x9F, 0xD8, 0x8D, 0x82,
- 0xCF, 0xCE, 0xBE, 0xAE
+ 0xC1, 0xC0, 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x9F, 0x96, 0x83, 0x86, 0x84
};
- 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 =
+ 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 =
+ 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
+ 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 =
+ const string CURRENCY = "¢£¥";
+ readonly byte[] _currencyBytes =
{
- 0xAD, 0xB0, 0xB1, 0xB2, 0xB3, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBD, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6,
- 0xD6, 0xD7
+ 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]
@@ -91,45 +106,45 @@ namespace Claunia.Encoding.Tests
byte[] byteArray;
string testString;
- byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Basque);
+ byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.BASQUE);
testString = Encoding.LisaEncoding.GetString(byteArray);
- Assert.AreEqual(Pangrams.Basque, testString);
- byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Breton);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ Assert.AreEqual(Pangrams.SPANISH, testString);
+ byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.SWEDISH);
testString = Encoding.LisaEncoding.GetString(byteArray);
- Assert.AreEqual(Pangrams.Swedish, testString);
+ Assert.AreEqual(Pangrams.SWEDISH, testString);
}
[Test]
@@ -137,32 +152,32 @@ namespace Claunia.Encoding.Tests
{
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(UpperLatin, testString);
- testString = Encoding.LisaEncoding.GetString(LowerLatinBytes);
- Assert.AreEqual(LowerLatin, 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]
@@ -170,32 +185,32 @@ namespace Claunia.Encoding.Tests
{
byte[] byteArray;
- byteArray = Encoding.LisaEncoding.GetBytes(Punctuations);
- Assert.AreEqual(PunctuationsBytes, byteArray);
- byteArray = Encoding.LisaEncoding.GetBytes(Digits);
- Assert.AreEqual(DigitsBytes, byteArray);
- byteArray = Encoding.LisaEncoding.GetBytes(UpperLatin);
- Assert.AreEqual(UpperLatinBytes, byteArray);
- byteArray = Encoding.LisaEncoding.GetBytes(LowerLatin);
- 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 fc87999..dbc63eb 100644
--- a/Claunia.Encoding.Tests/Radix50.cs
+++ b/Claunia.Encoding.Tests/Radix50.cs
@@ -31,26 +31,29 @@ namespace Claunia.Encoding.Tests
[TestFixture]
public class Radix50
{
- const string Punctuations = " .$%";
- readonly byte[] PunctuationsBytes = {0b00000001, 0b11000110, 0b11011101};
- const string Digits = "0123456789";
- readonly byte[] DigitsBytes =
+ 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 UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- readonly byte[] UpperLatinBytes =
+ 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
+ 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 SentencePadded = "THIS IS A TEST$ "; // It gets space padded when decoding is not multiple
- readonly byte[] SentenceBytes =
+ 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
+ 0b01010000, 0b10000010, 0b01010011, 0b00000000, 0b10010100, 0b11000000, 0b00000100, 0b00000101, 0b00000101,
+ 0b01001101, 0b01000110, 0b11000000
};
[Test]
@@ -58,14 +61,14 @@ namespace Claunia.Encoding.Tests
{
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(UpperLatin, testString);
- testString = Encoding.Radix50Encoding.GetString(SentenceBytes);
- Assert.AreEqual(SentencePadded, 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]
@@ -73,14 +76,14 @@ namespace Claunia.Encoding.Tests
{
byte[] byteArray;
- byteArray = Encoding.Radix50Encoding.GetBytes(Punctuations);
- Assert.AreEqual(PunctuationsBytes, byteArray);
- byteArray = Encoding.Radix50Encoding.GetBytes(Digits);
- Assert.AreEqual(DigitsBytes, byteArray);
- byteArray = Encoding.Radix50Encoding.GetBytes(UpperLatin);
- 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 95e4bfc..a41f80b 100644
--- a/Claunia.Encoding/ATASCII.cs
+++ b/Claunia.Encoding/ATASCII.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an ATARI Standard Code for Information Interchange character encoding of Unicode characters.
- ///
- public class ATASCII : Encoding
+ /// Represents an ATARI Standard Code for Information Interchange character encoding of Unicode characters.
+ public class Atascii : Encoding
{
- const string _bodyname = "atascii";
- const int _codepage = 0;
- const string _encodingname = "Atari Standard Code for Information Interchange";
- const string _headername = "atascii";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "atascii";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Atari Standard Code for Information Interchange";
+ const string HEADER_NAME = "atascii";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = true;
- ///
- /// The ATASCII to Unicode character map.
- ///
- static readonly char[] ATASCIITable =
+ /// The ATASCII to Unicode character map.
+ static readonly char[] _atasciiTable =
{
// 0x00
'\u2665', '\u251C', '\uFFFD', '\u2518', '\u2524', '\u2510', '\u2571', '\u2572',
+
// 0x08
'\u25E2', '\u2597', '\u25E3', '\u259D', '\u2598', '\uFFFD', '\u2582', '\u2596',
+
// 0x10
'\u2663', '\u250C', '\u2500', '\u253C', '\u25CF', '\u2584', '\u258E', '\u252C',
+
// 0x18
'\u2534', '\u258C', '\u2514', '\u001B', '\u2191', '\u2193', '\u2190', '\u2192',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u2666', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u2660', '\u007C', '\u21B0', '\u25C0', '\u25B6',
+
// 0x80
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x88
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x90
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x98
'\u0000', '\u0000', '\u0000', '\u000D', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xA0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xA8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xB0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xB8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xC0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xC8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xD0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xD8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xE0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xE8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xF0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xF8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0007', '\u0000', '\u0000'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a ATASCII character to an Unicode character
- ///
+ /// Converts a ATASCII character to an Unicode character
/// Unicode character.
/// ATASCII character.
- static char GetChar(byte character) => ATASCIITable[character];
+ static char GetChar(byte character) => _atasciiTable[character];
- ///
- /// Converts a Unicode character to an ATASCII character
- ///
+ /// Converts a Unicode character to an ATASCII character
/// ATASCII character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/Apple2.cs b/Claunia.Encoding/Apple2.cs
index 8a0647e..29bf10c 100644
--- a/Claunia.Encoding/Apple2.cs
+++ b/Claunia.Encoding/Apple2.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Apple II character encoding of Unicode characters.
- ///
+ /// Represents an Apple II character encoding of Unicode characters.
public class Apple2 : Encoding
{
- const string _bodyname = "apple2";
- const int _codepage = 0;
- const string _encodingname = "Western European (Apple II)";
- const string _headername = "apple2";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "apple2";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Western European (Apple II)";
+ const string HEADER_NAME = "apple2";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Apple II to Unicode character map.
- ///
- static readonly char[] Apple2Table =
+ /// The Apple II to Unicode character map.
+ static readonly char[] _apple2Table =
{
// 0x00
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x08
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x10
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x18
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x68
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x70
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x78
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x80
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x88
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x90
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x98
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xA0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xA8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xB0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xB8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xC0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xC8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xD0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xD8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xE0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xE8
'\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'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Apple II character to an Unicode character
- ///
+ /// Converts a Apple II character to an Unicode character
/// Unicode character.
/// Apple II character.
- static char GetChar(byte character) => Apple2Table[character];
+ static char GetChar(byte character) => _apple2Table[character];
- ///
- /// Converts a Unicode character to an Apple II character
- ///
+ /// Converts a Unicode character to an Apple II character
/// Apple II character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/Apple2c.cs b/Claunia.Encoding/Apple2c.cs
index 4034944..1134dcd 100644
--- a/Claunia.Encoding/Apple2c.cs
+++ b/Claunia.Encoding/Apple2c.cs
@@ -28,203 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Apple IIc character encoding of Unicode characters.
- ///
- public class Apple2c : Encoding
+ /// Represents an Apple IIc character encoding of Unicode characters.
+ public class Apple2C : Encoding
{
- const string _bodyname = "apple2c";
- const int _codepage = 0;
- const string _encodingname = "Western European (Apple IIc)";
- const string _headername = "apple2c";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "apple2c";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Western European (Apple IIc)";
+ const string HEADER_NAME = "apple2c";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Apple IIc to Unicode character map.
- /// Inverted screen characters are mapped to normal characters.
- ///
- static readonly char[] Apple2cTable =
+ /// The Apple IIc to Unicode character map. Inverted screen characters are mapped to normal characters.
+ static readonly char[] _apple2CTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u00A3', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x88
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x90
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x98
'\u0058', '\u0059', '\u005A', '\u005B', '\u00A3', '\u005D', '\u005E', '\u0020',
+
// 0xA0
'\u2588', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0xA8
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0xB0
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0xB8
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0xC0
'\u0000', '\u0000', '\u0000', '\u231B', '\u2713', '\u0000', '\u0000', '\u0000',
+
// 0xC8
'\u2190', '\u2026', '\u2193', '\u2191', '\u0000', '\u21B5', '\u0000', '\u0000',
+
// 0xD0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u2192', '\u0000', '\u0000',
+
// 0xD8
'\u0000', '\u0000', '\u0000', '\u25c6', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xE0
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0xE8
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0xF0
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0xF8
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -234,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -257,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -351,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Apple IIc character to an Unicode character
- ///
+ /// Converts a Apple IIc character to an Unicode character
/// Unicode character.
/// Apple IIc character.
- static char GetChar(byte character) => Apple2cTable[character];
+ static char GetChar(byte character) => _apple2CTable[character];
- ///
- /// Converts a Unicode character to an Apple IIc character
- ///
+ /// Converts a Unicode character to an Apple IIc character
/// Apple IIc character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/Apple2e.cs b/Claunia.Encoding/Apple2e.cs
index decedd9..b64ca1a 100644
--- a/Claunia.Encoding/Apple2e.cs
+++ b/Claunia.Encoding/Apple2e.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Apple IIe character encoding of Unicode characters.
- ///
- public class Apple2e : Encoding
+ /// Represents an Apple IIe character encoding of Unicode characters.
+ public class Apple2E : Encoding
{
- const string _bodyname = "apple2e";
- const int _codepage = 0;
- const string _encodingname = "Western European (Apple IIe)";
- const string _headername = "apple2e";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "apple2e";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Western European (Apple IIe)";
+ const string HEADER_NAME = "apple2e";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Apple IIe to Unicode character map.
- ///
- static readonly char[] Apple2eTable =
+ /// The Apple IIe to Unicode character map.
+ static readonly char[] _apple2ETable =
{
// 0x00
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x08
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x10
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x18
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x20
'\u0040', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x28
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x30
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x38
'\u0078', '\u0079', '\u007A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x40
'\u00A0', '\u2575', '\u2574', '\u2577', '\u2576', '\u2518', '\u2510', '\u250C',
+
// 0x48
'\u2514', '\u2500', '\u2502', '\u2534', '\u2524', '\u252C', '\u251C', '\u253C',
+
// 0x50
'\u25E4', '\u25E5', '\u2592', '\u2598', '\u259D', '\u2580', '\u2596', '\u2597',
+
// 0x58
'\u259A', '\u258C', '\u0000', '\u0000', '\u2190', '\u2191', '\u2192', '\u2193',
+
// 0x60
'\u03C0', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x68
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x70
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x78
'\u0058', '\u0059', '\u005A', '\u007B', '\u007C', '\u007D', '\u007E', '\u0000',
+
// 0x80
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x88
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x90
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x98
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xA0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xA8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xB0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xB8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xC0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xC8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xD0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xD8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xE0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xE8
'\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'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Apple IIe character to an Unicode character
- ///
+ /// Converts a Apple IIe character to an Unicode character
/// Unicode character.
/// Apple IIe character.
- static char GetChar(byte character) => Apple2eTable[character];
+ static char GetChar(byte character) => _apple2ETable[character];
- ///
- /// Converts a Unicode character to an Apple IIe character
- ///
+ /// Converts a Unicode character to an Apple IIe character
/// Apple IIe character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/Apple2gs.cs b/Claunia.Encoding/Apple2gs.cs
index 66fdd79..cff2c41 100644
--- a/Claunia.Encoding/Apple2gs.cs
+++ b/Claunia.Encoding/Apple2gs.cs
@@ -28,203 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Apple IIgs character encoding of Unicode characters.
- ///
- public class Apple2gs : Encoding
+ /// Represents an Apple IIgs character encoding of Unicode characters.
+ public class Apple2Gs : Encoding
{
- const string _bodyname = "apple2gs";
- const int _codepage = 0;
- const string _encodingname = "Western European (Apple IIgs)";
- const string _headername = "apple2gs";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "apple2gs";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Western European (Apple IIgs)";
+ const string HEADER_NAME = "apple2gs";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Apple IIgs to Unicode character map.
- /// Inverted screen characters are mapped to normal characters.
- ///
- static readonly char[] Apple2gsTable =
+ /// The Apple IIgs to Unicode character map. Inverted screen characters are mapped to normal characters.
+ static readonly char[] _apple2GsTable =
{
// 0x00
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x08
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x10
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x18
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u0020',
+
// 0x20
'\u2588', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0000', '\u0000', '\u0000', '\u231B', '\u2713', '\u0000', '\u0000', '\u0000',
+
// 0x48
'\u2190', '\u2026', '\u2193', '\u2191', '\u0000', '\u21B5', '\u0000', '\u0000',
+
// 0x50
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u2192', '\u0000', '\u0000',
+
// 0x58
'\u0000', '\u0000', '\u0000', '\u25C6', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u0000',
+
// 0x80
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x88
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x90
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x98
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0xA0
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0xA8
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0xB0
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0xB8
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0xC0
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0xC8
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0xD0
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0xD8
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0xE0
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0xE8
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0xF0
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0xF8
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u0000'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -234,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -257,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -351,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Apple IIgs character to an Unicode character
- ///
+ /// Converts a Apple IIgs character to an Unicode character
/// Unicode character.
/// Apple IIgs character.
- static char GetChar(byte character) => Apple2gsTable[character];
+ static char GetChar(byte character) => _apple2GsTable[character];
- ///
- /// Converts a Unicode character to an Apple IIgs character
- ///
+ /// Converts a Unicode character to an Apple IIgs character
/// Apple IIgs character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/AtariST.cs b/Claunia.Encoding/AtariST.cs
index 09ece44..9b1fd88 100644
--- a/Claunia.Encoding/AtariST.cs
+++ b/Claunia.Encoding/AtariST.cs
@@ -28,203 +28,209 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Atari ST character encoding of Unicode characters.
- ///
+ /// Represents an Atari ST character encoding of Unicode characters.
+
// TODO: 0x09 => U+1F552, 0x0A => U+1F514
- public class AtariST : Encoding
+ public class AtariSt : Encoding
{
- const string _bodyname = "atarist";
- const int _codepage = 0;
- const string _encodingname = "Western European (Atari ST)";
- const string _headername = "atarist";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "atarist";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Western European (Atari ST)";
+ const string HEADER_NAME = "atarist";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Atari ST to Unicode character map.
- ///
- static readonly char[] AtariSTTable =
+ /// The Atari ST to Unicode character map.
+ static readonly char[] _atariStTable =
{
// 0x00
'\u0000', '\u21E7', '\u21E9', '\u21E8', '\u21E6', '\u274E', '\uFFFD', '\uFFFD',
+
// 0x08
'\u2713', '\uFFFD', '\uFFFD', '\u266A', '\u000C', '\u000D', '\uFFFD', '\uFFFD',
+
// 0x10
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0x18
'\uFFFD', '\uFFFD', '\u0259', '\u001B', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u2302',
+
// 0x80
'\u00C7', '\u00FC', '\u00E9', '\u00E2', '\u00E4', '\u00E0', '\u00E5', '\u00E7',
+
// 0x88
'\u00EA', '\u00EB', '\u00E8', '\u00EF', '\u00EE', '\u00EC', '\u00C4', '\u00C5',
+
// 0x90
'\u00C9', '\u00E6', '\u00C6', '\u00F4', '\u00F6', '\u00F2', '\u00FB', '\u00F9',
+
// 0x98
'\u00FF', '\u00D6', '\u00DC', '\u00A2', '\u00A3', '\u00A5', '\u00DF', '\u0192',
+
// 0xA0
'\u00E1', '\u00ED', '\u00F3', '\u00FA', '\u00F1', '\u00D1', '\u00AA', '\u00BA',
+
// 0xA8
'\u00BF', '\u2310', '\u00AC', '\u00BD', '\u00BC', '\u00A1', '\u00AB', '\u00BB',
+
// 0xB0
'\u00E3', '\u00F5', '\u00D8', '\u00F8', '\u0153', '\u0152', '\u00C0', '\u00C3',
+
// 0xB8
'\u00D5', '\u00A8', '\u00B4', '\u2020', '\u00B6', '\u00A9', '\u00AE', '\u2122',
+
// 0xC0
'\u0133', '\u0132', '\u05D0', '\u05D1', '\u05D2', '\u05D3', '\u05D4', '\u05D5',
+
// 0xC8
'\u05D6', '\u05D7', '\u05D8', '\u05D9', '\u05DB', '\u05DC', '\u05DE', '\u05E0',
+
// 0xD0
'\u05E1', '\u05E2', '\u05E4', '\u05E6', '\u05E7', '\u05E8', '\u05E9', '\u05EA',
+
// 0xD8
'\u05DF', '\u05DA', '\u05DD', '\u05E3', '\u05E5', '\u00A7', '\u2227', '\u221E',
+
// 0xE0
'\u03B1', '\u03B2', '\u0393', '\u03C0', '\u03A3', '\u03C3', '\u00B5', '\u03C4',
+
// 0xE8
'\u03A6', '\u0398', '\u03A9', '\u03B4', '\u222E', '\u03D5', '\u2208', '\u2229',
+
// 0xF0
'\u2261', '\u00B1', '\u2265', '\u2264', '\u2320', '\u2321', '\u00F7', '\u2248',
+
// 0xF8
'\u00B0', '\u2219', '\u00B7', '\u221A', '\u207F', '\u00B2', '\u00B3', '\u00AF'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -234,21 +240,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -257,92 +260,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -351,119 +363,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Atari ST character to an Unicode character
- ///
+ /// Converts a Atari ST character to an Unicode character
/// Unicode character.
/// Atari ST character.
- static char GetChar(byte character) => AtariSTTable[character];
+ static char GetChar(byte character) => _atariStTable[character];
- ///
- /// Converts a Unicode character to an Atari ST character
- ///
+ /// Converts a Unicode character to an Atari ST character
/// Atari ST character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/Claunia.Encoding.csproj b/Claunia.Encoding/Claunia.Encoding.csproj
index 4a0fc72..dfedbfe 100644
--- a/Claunia.Encoding/Claunia.Encoding.csproj
+++ b/Claunia.Encoding/Claunia.Encoding.csproj
@@ -8,7 +8,7 @@
Claunia.Encoding
true
Claunia.Encoding
- 1.8
+ 1.9
Natalia Portillo
Natalia Portillo
https://github.com/claunia/Claunia.Encoding
diff --git a/Claunia.Encoding/Encoding.cs b/Claunia.Encoding/Encoding.cs
index 3c9556c..569c57c 100644
--- a/Claunia.Encoding/Encoding.cs
+++ b/Claunia.Encoding/Encoding.cs
@@ -31,115 +31,74 @@ using System.Reflection;
namespace Claunia.Encoding
{
- ///
- /// This class contains static instances of the supported encodings.
- ///
+ /// This class contains static instances of the supported encodings.
public abstract class Encoding : System.Text.Encoding
{
- ///
- /// Static instance for the LisaRoman 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
- ///
+ /// 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
- ///
+ /// Static instance for the GEM encoding
public static System.Text.Encoding GemEncoding = new Gem();
- ///
- /// Static instance for the GEM encoding
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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.
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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
- ///
+ /// 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
- ///
+ /// Gets a name for the current encoding that can be used with mail agent header tags
public abstract override string HeaderName { get; }
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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))
- let encoding = (Encoding)type.GetConstructor(new Type[] { }).Invoke(new object[] { })
- select new EncodingInfo(encoding.CodePage, encoding.BodyName, encoding.EncodingName, false, type))
- .ToArray();
+ (from type in Assembly.GetExecutingAssembly().GetTypes() where type.IsSubclassOf(typeof(Encoding))
+ let encoding = (Encoding)type.GetConstructor(new Type[]
+ {}).Invoke(new object[]
+ {}) select new
+ EncodingInfo(encoding.CodePage, encoding.BodyName, encoding.EncodingName, false, type)).ToArray();
- ///
- /// Returns the encoding associated with the specified code page name.
- ///
+ /// 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.
@@ -150,8 +109,12 @@ namespace Claunia.Encoding
foreach(Type type in Assembly.GetExecutingAssembly().GetTypes())
if(type.IsSubclassOf(typeof(Encoding)))
{
- Encoding encoding = (Encoding)type.GetConstructor(new Type[] { }).Invoke(new object[] { });
- if(encoding.BodyName == name.ToLowerInvariant()) return encoding;
+ var encoding = (Encoding)type.GetConstructor(new Type[]
+ {}).Invoke(new object[]
+ {});
+
+ if(encoding.BodyName == name.ToLowerInvariant())
+ return encoding;
}
return System.Text.Encoding.GetEncoding(name);
diff --git a/Claunia.Encoding/EncodingInfo.cs b/Claunia.Encoding/EncodingInfo.cs
index 1734d3f..53ddfe5 100644
--- a/Claunia.Encoding/EncodingInfo.cs
+++ b/Claunia.Encoding/EncodingInfo.cs
@@ -6,54 +6,44 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Provides basic information about an encoding.
- ///
+ /// Provides basic information about an encoding.
public sealed class EncodingInfo
{
- bool isSystem;
- readonly Type thisType;
+ readonly Type _thisType;
+ bool _isSystem;
- internal EncodingInfo(int codePage, string name, string displayName, bool system = true,
+ internal EncodingInfo(int codePage, string name, string displayName, bool system = true,
Type internalType = null)
{
CodePage = codePage;
Name = name;
DisplayName = displayName;
- isSystem = system;
- thisType = internalType;
+ _isSystem = system;
+ _thisType = internalType;
}
- ///
- /// Gets the code page identifier of the encoding.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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[] { });
+ 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.
- ///
+ /// 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
@@ -61,9 +51,7 @@ namespace Claunia.Encoding
///
public override bool Equals(object value) => value is EncodingInfo that && CodePage == that.CodePage;
- ///
- /// Returns the hash code for the current EncodingInfo object.
- ///
+ /// Returns the hash code for the current EncodingInfo object.
/// A 32-bit signed integer hash code.
public override int GetHashCode() => CodePage;
}
diff --git a/Claunia.Encoding/Gem.cs b/Claunia.Encoding/Gem.cs
index cf37031..57968cd 100644
--- a/Claunia.Encoding/Gem.cs
+++ b/Claunia.Encoding/Gem.cs
@@ -28,203 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents a GEM character encoding of Unicode characters.
- ///
+ /// Represents a GEM character encoding of Unicode characters.
public class Gem : Encoding
{
- const string _bodyname = "gem";
- const int _codepage = 0;
- const string _encodingname = "Western European (GEM)";
- const string _headername = "gem";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "gem";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Western European (GEM)";
+ const string HEADER_NAME = "gem";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = true;
- ///
- /// The GEM to Unicode character map.
- /// Pending: 0x09 => 0x0001F552, 0x0A => 0x0001F514
- ///
- static readonly char[] GemTable =
+ /// The GEM to Unicode character map. Pending: 0x09 => 0x0001F552, 0x0A => 0x0001F514
+ static readonly char[] _gemTable =
{
// 0x00
'\u0000', '\u21E7', '\u21E9', '\u21E8', '\u21E6', '\u25FC', '\uFFFD', '\u25C6',
+
// 0x08
'\u2713', '\uFFFD', '\uFFFD', '\u266A', '\u25B4', '\u25BE', '\u25B8', '\u25C2',
+
// 0x10
'\u25BA', '\u25C4', '\u29D3', '\u2582', '\u00B6', '\u00A7', '\u2195', '\u21A8',
+
// 0x18
'\u2191', '\u2193', '\u2192', '\u2190', '\u221F', '\u2194', '\u25B2', '\u25BC',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u2302',
+
// 0x80
'\u00C7', '\u00FC', '\u00E9', '\u00E2', '\u00E4', '\u00E0', '\u00E5', '\u00E7',
+
// 0x88
'\u00EA', '\u00EB', '\u00E8', '\u00EF', '\u00EE', '\u00EC', '\u00C4', '\u00C5',
+
// 0x90
'\u00C9', '\u00E6', '\u00C6', '\u00F4', '\u00F6', '\u00F2', '\u00FB', '\u00F9',
+
// 0x98
'\u00FF', '\u00D6', '\u00DC', '\u00FB', '\u00A3', '\u00D8', '\u00A4', '\u0192',
+
// 0xA0
'\u00E1', '\u00ED', '\u00F3', '\u00FA', '\u00F1', '\u00D1', '\u00AA', '\u00BA',
+
// 0xA8
'\u00BF', '\u201C', '\u201D', '\u2039', '\u203A', '\u00A1', '\u00AB', '\u00BB',
+
// 0xB0
'\u00E3', '\u00F5', '\u00A5', '\u00A2', '\u0153', '\u0152', '\u00C0', '\u00C3',
+
// 0xB8
'\u00D5', '\u00A7', '\u2021', '\u2020', '\u00B6', '\u00A9', '\u00AE', '\u2122',
+
// 0xC0
'\u201E', '\u2026', '\u2030', '\u2022', '\u2013', '\u2014', '\u2070', '\u00C1',
+
// 0xC8
'\u00C2', '\u00C8', '\u00CA', '\u00CB', '\u00CC', '\u00CD', '\u00CE', '\u00CF',
+
// 0xD0
'\u00D2', '\u00D3', '\u00D4', '\u0160', '\u0161', '\u00D9', '\u00DA', '\u00DB',
+
// 0xD8
'\u0178', '\u00DF', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xE0
'\u03B1', '\u03B2', '\u0393', '\u03C0', '\u03A3', '\u03C3', '\u00B5', '\u03C4',
+
// 0xE8
'\u03A6', '\u0398', '\u03A9', '\u03B4', '\u222E', '\u0278', '\u2208', '\u2229',
+
// 0xF0
'\u2261', '\u00B1', '\u2265', '\u2264', '\u2320', '\u2321', '\u00F7', '\u2248',
+
// 0xF8
'\u00B0', '\u2219', '\u00B7', '\u221A', '\u207F', '\u00B2', '\u25A0', '\u2205'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -234,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -257,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -351,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a GEM character to an Unicode character
- ///
+ /// Converts a GEM character to an Unicode character
/// Unicode character.
/// GEM character.
- static char GetChar(byte character) => GemTable[character];
+ static char GetChar(byte character) => _gemTable[character];
- ///
- /// Converts a Unicode character to an GEM character
- ///
+ /// Converts a Unicode character to an GEM character
/// GEM character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/Geos.cs b/Claunia.Encoding/Geos.cs
index 0060e5e..2d42a20 100644
--- a/Claunia.Encoding/Geos.cs
+++ b/Claunia.Encoding/Geos.cs
@@ -28,204 +28,210 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an GEOS character encoding of Unicode characters.
- ///
+ /// Represents an GEOS character encoding of Unicode characters.
public class Geos : Encoding
{
- const string _bodyname = "geos";
- const int _codepage = 0;
- const string _encodingname = "Western European (GEOS)";
- const string _headername = "geos";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "geos";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Western European (GEOS)";
+ const string HEADER_NAME = "geos";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = 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.
+ /// The GEOS to Unicode character map. In the GEOS character map application lots of positions appears as '\u002E'
+ /// ('.' period) in normal (non-symbol) fonts.
///
- static readonly char[] GeosTable =
+ static readonly char[] _geosTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
+
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
+
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
+
// 0x98
'\u00F2', '\u00F4', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC', '\u2020',
+
// 0xA0
'\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u00B7', '\u00B6', '\u00DF', '\u00AE',
+
// 0xA8
'\u00A9', '\u2122', '\u0022', '\u0027', '\u002E', '\u00C6', '\u00D8', '\u221E',
+
// 0xB0
'\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u002E', '\u002E', '\u002E',
+
// 0xB8
'\u03C0', '\u002E', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8', '\u00BF',
+
// 0xC0
'\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u002E', '\u00AB', '\u00BB',
+
// 0xC8
'\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153', '\u2013',
+
// 0xD0
'\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u002E', '\u00FF',
+
// 0xD8
'\u0178', '\u002E', '\u00A4', '\u2039', '\u203A', '\u00FD', '\u00DD', '\u2021',
+
// 0xE0
'\u002E', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1', '\u00CB',
+
// 0xE8
'\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4', '\u002E',
+
// 0xF0
'\u00D2', '\u00DA', '\u00D9', '\u00B9', '\u20C6', '\u20DC', '\u00AF', '\u02C7',
+
// 0xF8
'\u00B7', '\u00B0', '\u00B8', '\u2032', '\u02DB', '\u02D8', '\u00A0', '\u002E'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -235,21 +241,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -258,92 +261,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -352,119 +364,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a GEOS character to an Unicode character
- ///
+ /// Converts a GEOS character to an Unicode character
/// Unicode character.
/// GEOS character.
- static char GetChar(byte character) => GeosTable[character];
+ static char GetChar(byte character) => _geosTable[character];
- ///
- /// Converts a Unicode character to an GEOS character
- ///
+ /// Converts a Unicode character to an GEOS character
/// GEOS character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/LisaRoman.cs b/Claunia.Encoding/LisaRoman.cs
index 983f201..897c85a 100644
--- a/Claunia.Encoding/LisaRoman.cs
+++ b/Claunia.Encoding/LisaRoman.cs
@@ -28,203 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Apple Lisa character encoding of Unicode characters.
- ///
+ /// Represents an Apple Lisa character encoding of Unicode characters.
public class LisaRoman : Encoding
{
- const string _bodyname = "lisa";
- const int _codepage = 0;
- const string _encodingname = "Western European (Apple Lisa)";
- const string _headername = "lisa";
- const string _webname = "";
- const int _windowsCodepage = 10000;
+ const string BODY_NAME = "lisa";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Western European (Apple Lisa)";
+ const string HEADER_NAME = "lisa";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 10000;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Lisa to Unicode character map.
- /// MacRoman is a superset of LisaRoman.
- ///
- static readonly char[] LisaRomanTable =
+ /// The Lisa to Unicode character map. MacRoman is a superset of LisaRoman.
+ static readonly char[] _lisaRomanTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u2588',
+
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
+
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
+
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
+
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
+
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
+
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8',
+
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211',
+
// 0xB8
'\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8',
+
// 0xC0
'\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
+
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153',
+
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
+
// 0xD8
'\u00FF', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xE0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xE8
'\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'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -234,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -257,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -351,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a LisaRoman character to an Unicode character
- ///
+ /// Converts a LisaRoman character to an Unicode character
/// Unicode character.
/// LisaRoman character.
- static char GetChar(byte character) => LisaRomanTable[character];
+ static char GetChar(byte character) => _lisaRomanTable[character];
- ///
- /// Converts a Unicode character to an LisaRoman character
- ///
+ /// Converts a Unicode character to an LisaRoman character
/// LisaRoman character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacArabic.cs b/Claunia.Encoding/MacArabic.cs
index a2cb9e1..a60ac95 100644
--- a/Claunia.Encoding/MacArabic.cs
+++ b/Claunia.Encoding/MacArabic.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Mac Arabic character encoding of Unicode characters.
- ///
+ /// Represents an Mac Arabic character encoding of Unicode characters.
public class MacArabic : Encoding
{
- const string _bodyname = "x-mac-arabic";
- const int _codepage = 10004;
- const string _encodingname = "Arabic (Mac)";
- const string _headername = "x-mac-arabic";
- const string _webname = "x-mac-arabic";
- const int _windowsCodepage = 10004;
+ const string BODY_NAME = "x-mac-arabic";
+ const int CODEPAGE = 10004;
+ const string ENCODING_NAME = "Arabic (Mac)";
+ const string HEADER_NAME = "x-mac-arabic";
+ const string WEB_NAME = "x-mac-arabic";
+ const int WINDOWS_CODEPAGE = 10004;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Macintosh Arabic to Unicode character map.
- ///
- static readonly char[] MacArabicTable =
+ /// The Macintosh Arabic to Unicode character map.
+ static readonly char[] _macArabicTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u00C4', '\u00A0', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
+
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u06BA', '\u00AB', '\u00E7', '\u00E9', '\u00E8',
+
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u2026', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
+
// 0x98
'\u00BB', '\u00F4', '\u00F6', '\u00F7', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
+
// 0xA0
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u066A', '\u0026', '\u0027',
+
// 0xA8
'\u0028', '\u0029', '\u002A', '\u002B', '\u060C', '\u002D', '\u002E', '\u002F',
+
// 0xB0
'\u0660', '\u0661', '\u0662', '\u0663', '\u0664', '\u0665', '\u0666', '\u0667',
+
// 0xB8
'\u0668', '\u0669', '\u003A', '\u061B', '\u003C', '\u003D', '\u003E', '\u061F',
+
// 0xC0
'\u274A', '\u0621', '\u0622', '\u0623', '\u0624', '\u0625', '\u0626', '\u0627',
+
// 0xC8
'\u0628', '\u0629', '\u062A', '\u062B', '\u062C', '\u062D', '\u062E', '\u062F',
+
// 0xD0
'\u0630', '\u0631', '\u0632', '\u0633', '\u0634', '\u0635', '\u0636', '\u0637',
+
// 0xD8
'\u0638', '\u0639', '\u063A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0xE0
'\u0640', '\u0641', '\u0642', '\u0643', '\u0644', '\u0645', '\u0646', '\u0647',
+
// 0xE8
'\u0648', '\u0649', '\u064A', '\u064B', '\u064C', '\u064D', '\u064E', '\u064F',
+
// 0xF0
'\u0650', '\u0651', '\u0652', '\u067E', '\u0679', '\u0686', '\u06D5', '\u06A4',
+
// 0xF8
'\u06AF', '\u0688', '\u0691', '\u007B', '\u007C', '\u007D', '\u0698', '\u06D2'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Mac Arabic character to an Unicode character
- ///
+ /// Converts a Mac Arabic character to an Unicode character
/// Unicode character.
/// Mac Arabic character.
- static char GetChar(byte character) => MacArabicTable[character];
+ static char GetChar(byte character) => _macArabicTable[character];
- ///
- /// Converts a Unicode character to an Mac Arabic character
- ///
+ /// Converts a Unicode character to an Mac Arabic character
/// Mac Arabic character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacCentralEuropean.cs b/Claunia.Encoding/MacCentralEuropean.cs
index 0c44232..e7689e4 100644
--- a/Claunia.Encoding/MacCentralEuropean.cs
+++ b/Claunia.Encoding/MacCentralEuropean.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Mac CentralEuropean character encoding of Unicode characters.
- ///
+ /// Represents an Mac CentralEuropean character encoding of Unicode characters.
public class MacCentralEuropean : Encoding
{
- const string _bodyname = "x-mac-ce";
- const int _codepage = 10029;
- const string _encodingname = "Central European (Mac)";
- const string _headername = "x-mac-ce";
- const string _webname = "x-mac-ce";
- const int _windowsCodepage = 10029;
+ const string BODY_NAME = "x-mac-ce";
+ const int CODEPAGE = 10029;
+ const string ENCODING_NAME = "Central European (Mac)";
+ const string HEADER_NAME = "x-mac-ce";
+ const string WEB_NAME = "x-mac-ce";
+ const int WINDOWS_CODEPAGE = 10029;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Macintosh CentralEuropean to Unicode character map.
- ///
- static readonly char[] MacCentralEuropeanTable =
+ /// The Macintosh CentralEuropean to Unicode character map.
+ static readonly char[] _macCentralEuropeanTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u00C4', '\u0100', '\u0101', '\u00C9', '\u0104', '\u00D6', '\u00DC', '\u00E1',
+
// 0x88
'\u0105', '\u010C', '\u00E4', '\u010D', '\u0106', '\u0107', '\u00E9', '\u0179',
+
// 0x90
'\u017A', '\u010E', '\u00ED', '\u010F', '\u0112', '\u0113', '\u0116', '\u00F3',
+
// 0x98
'\u0117', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u011A', '\u011B', '\u00FC',
+
// 0xA0
'\u2020', '\u00B0', '\u0118', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
+
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u0119', '\u00A8', '\u2260', '\u0123', '\u012E',
+
// 0xB0
'\u012F', '\u012A', '\u2264', '\u2265', '\u012B', '\u0136', '\u2202', '\u2211',
+
// 0xB8
'\u0142', '\u013B', '\u013C', '\u013D', '\u013E', '\u0139', '\u013A', '\u0145',
+
// 0xC0
'\u0146', '\u0143', '\u00AC', '\u221A', '\u0144', '\u0147', '\u2206', '\u00AB',
+
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u0148', '\u0150', '\u00D5', '\u0151', '\u014C',
+
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
+
// 0xD8
'\u014D', '\u0154', '\u0155', '\u0158', '\u2039', '\u203A', '\u0159', '\u0156',
+
// 0xE0
'\u0157', '\u0160', '\u201A', '\u201E', '\u0161', '\u015A', '\u015B', '\u00C1',
+
// 0xE8
'\u0164', '\u0165', '\u00CD', '\u017D', '\u017E', '\u016A', '\u00D3', '\u00D4',
+
// 0xF0
'\u016B', '\u016E', '\u00DA', '\u016F', '\u0170', '\u0171', '\u0172', '\u0173',
+
// 0xF8
'\u00DD', '\u00FD', '\u0137', '\u017B', '\u0141', '\u017C', '\u0122', '\u02C7'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Mac CentralEuropean character to an Unicode character
- ///
+ /// Converts a Mac CentralEuropean character to an Unicode character
/// Unicode character.
/// Mac CentralEuropean character.
- static char GetChar(byte character) => MacCentralEuropeanTable[character];
+ static char GetChar(byte character) => _macCentralEuropeanTable[character];
- ///
- /// Converts a Unicode character to an Mac CentralEuropean character
- ///
+ /// Converts a Unicode character to an Mac CentralEuropean character
/// Mac CentralEuropean character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacCroatian.cs b/Claunia.Encoding/MacCroatian.cs
index 429d184..096ab77 100644
--- a/Claunia.Encoding/MacCroatian.cs
+++ b/Claunia.Encoding/MacCroatian.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Mac Croatian character encoding of Unicode characters.
- ///
+ /// Represents an Mac Croatian character encoding of Unicode characters.
public class MacCroatian : Encoding
{
- const string _bodyname = "x-mac-croatian";
- const int _codepage = 10082;
- const string _encodingname = "Croatian (Mac)";
- const string _headername = "x-mac-croatian";
- const string _webname = "x-mac-croatian";
- const int _windowsCodepage = 10082;
+ const string BODY_NAME = "x-mac-croatian";
+ const int CODEPAGE = 10082;
+ const string ENCODING_NAME = "Croatian (Mac)";
+ const string HEADER_NAME = "x-mac-croatian";
+ const string WEB_NAME = "x-mac-croatian";
+ const int WINDOWS_CODEPAGE = 10082;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Macintosh Croatian to Unicode character map.
- ///
- static readonly char[] MacCroatianTable =
+ /// The Macintosh Croatian to Unicode character map.
+ static readonly char[] _macCroatianTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
+
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
+
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
+
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
+
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
+
// 0xA8
'\u00AE', '\u0160', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u017D', '\u00D8',
+
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u2206', '\u00B5', '\u2202', '\u2211',
+
// 0xB8
'\u220F', '\u0161', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u017E', '\u00F8',
+
// 0xC0
'\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u0106', '\u00AB',
+
// 0xC8
'\u010C', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153',
+
// 0xD0
'\u0110', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
+
// 0xD8
'\uF8FF', '\u00A9', '\u2044', '\u20AC', '\u2039', '\u203A', '\u00C6', '\u00BB',
+
// 0xE0
'\u2013', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u0107', '\u00C1',
+
// 0xE8
'\u010D', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4',
+
// 0xF0
'\u0111', '\u00D2', '\u00DA', '\u00D8', '\u00D9', '\u0131', '\u02C6', '\u02DC',
+
// 0xF8
'\u00AF', '\u03C0', '\u00CB', '\u02DA', '\u00B8', '\u00CA', '\u00E6', '\u02C7'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Mac Croatian character to an Unicode character
- ///
+ /// Converts a Mac Croatian character to an Unicode character
/// Unicode character.
/// Mac Croatian character.
- static char GetChar(byte character) => MacCroatianTable[character];
+ static char GetChar(byte character) => _macCroatianTable[character];
- ///
- /// Converts a Unicode character to an Mac Croatian character
- ///
+ /// Converts a Unicode character to an Mac Croatian character
/// Mac Croatian character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacCyrillic.cs b/Claunia.Encoding/MacCyrillic.cs
index 7de6118..47c5e8a 100644
--- a/Claunia.Encoding/MacCyrillic.cs
+++ b/Claunia.Encoding/MacCyrillic.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Mac Cyrillic character encoding of Unicode characters.
- ///
+ /// Represents an Mac Cyrillic character encoding of Unicode characters.
public class MacCyrillic : Encoding
{
- const string _bodyname = "x-mac-cyrillic";
- const int _codepage = 10007;
- const string _encodingname = "Cyrillic (Mac)";
- const string _headername = "x-mac-cyrillic";
- const string _webname = "x-mac-cyrillic";
- const int _windowsCodepage = 10007;
+ const string BODY_NAME = "x-mac-cyrillic";
+ const int CODEPAGE = 10007;
+ const string ENCODING_NAME = "Cyrillic (Mac)";
+ const string HEADER_NAME = "x-mac-cyrillic";
+ const string WEB_NAME = "x-mac-cyrillic";
+ const int WINDOWS_CODEPAGE = 10007;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Macintosh Cyrillic to Unicode character map.
- ///
- static readonly char[] MacCyrillicTable =
+ /// The Macintosh Cyrillic to Unicode character map.
+ static readonly char[] _macCyrillicTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416', '\u0417',
+
// 0x88
'\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D', '\u041E', '\u041F',
+
// 0x90
'\u0420', '\u0421', '\u0422', '\u0423', '\u0424', '\u0425', '\u0426', '\u0427',
+
// 0x98
'\u0428', '\u0429', '\u042A', '\u042B', '\u042C', '\u042D', '\u042E', '\u042F',
+
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u0406',
+
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u0402', '\u0452', '\u2260', '\u0403', '\u0453',
+
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u0456', '\u00B5', '\u2202', '\u0408',
+
// 0xB8
'\u0404', '\u0454', '\u0407', '\u0457', '\u0409', '\u0459', '\u040A', '\u045A',
+
// 0xC0
'\u0458', '\u0405', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
+
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u040B', '\u045B', '\u040C', '\u045C', '\u0455',
+
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u201E',
+
// 0xD8
'\u040E', '\u045E', '\u040F', '\u045F', '\u2116', '\u0401', '\u0451', '\u044F',
+
// 0xE0
'\u0430', '\u0431', '\u0432', '\u0433', '\u0434', '\u0435', '\u0436', '\u0437',
+
// 0xE8
'\u0438', '\u0439', '\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F',
+
// 0xF0
'\u0440', '\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447',
+
// 0xF8
'\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E', '\u20AC'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Mac Cyrillic character to an Unicode character
- ///
+ /// Converts a Mac Cyrillic character to an Unicode character
/// Unicode character.
/// Mac Cyrillic character.
- static char GetChar(byte character) => MacCyrillicTable[character];
+ static char GetChar(byte character) => _macCyrillicTable[character];
- ///
- /// Converts a Unicode character to an Mac Cyrillic character
- ///
+ /// Converts a Unicode character to an Mac Cyrillic character
/// Mac Cyrillic character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacFarsi.cs b/Claunia.Encoding/MacFarsi.cs
index 7d5560c..32a4d59 100644
--- a/Claunia.Encoding/MacFarsi.cs
+++ b/Claunia.Encoding/MacFarsi.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Mac Farsi character encoding of Unicode characters.
- ///
+ /// Represents an Mac Farsi character encoding of Unicode characters.
public class MacFarsi : Encoding
{
- const string _bodyname = "x-mac-farsi";
- const int _codepage = 10014;
- const string _encodingname = "Farsi (Mac)";
- const string _headername = "x-mac-farsi";
- const string _webname = "x-mac-farsi";
- const int _windowsCodepage = 10014;
+ const string BODY_NAME = "x-mac-farsi";
+ const int CODEPAGE = 10014;
+ const string ENCODING_NAME = "Farsi (Mac)";
+ const string HEADER_NAME = "x-mac-farsi";
+ const string WEB_NAME = "x-mac-farsi";
+ const int WINDOWS_CODEPAGE = 10014;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Macintosh Farsi to Unicode character map.
- ///
- static readonly char[] MacFarsiTable =
+ /// The Macintosh Farsi to Unicode character map.
+ static readonly char[] _macFarsiTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u00C4', '\u00A0', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
+
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u06BA', '\u00AB', '\u00E7', '\u00E9', '\u00E8',
+
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u2026', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
+
// 0x98
'\u00BB', '\u00F4', '\u00F6', '\u00F7', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
+
// 0xA0
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u066A', '\u0026', '\u0027',
+
// 0xA8
'\u0028', '\u0029', '\u002A', '\u002B', '\u060C', '\u002D', '\u002E', '\u002F',
+
// 0xB0
'\u06F0', '\u06F1', '\u06F2', '\u06F3', '\u06F4', '\u06F5', '\u06F6', '\u06F7',
+
// 0xB8
'\u06F8', '\u06F9', '\u003A', '\u061B', '\u003C', '\u003D', '\u003E', '\u061F',
+
// 0xC0
'\u274A', '\u0621', '\u0622', '\u0623', '\u0624', '\u0625', '\u0626', '\u0627',
+
// 0xC8
'\u0628', '\u0629', '\u062A', '\u062B', '\u062C', '\u062D', '\u062E', '\u062F',
+
// 0xD0
'\u0630', '\u0631', '\u0632', '\u0633', '\u0634', '\u0635', '\u0636', '\u0637',
+
// 0xD8
'\u0638', '\u0639', '\u063A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0xE0
'\u0640', '\u0641', '\u0642', '\u0643', '\u0644', '\u0645', '\u0646', '\u0647',
+
// 0xE8
'\u0648', '\u0649', '\u064A', '\u064B', '\u064C', '\u064D', '\u064E', '\u064F',
+
// 0xF0
'\u0650', '\u0651', '\u0652', '\u067E', '\u0679', '\u0686', '\u06D5', '\u06A4',
+
// 0xF8
'\u06AF', '\u0688', '\u0691', '\u007B', '\u007C', '\u007D', '\u0698', '\u06D2'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Mac Farsi character to an Unicode character
- ///
+ /// Converts a Mac Farsi character to an Unicode character
/// Unicode character.
/// Mac Farsi character.
- static char GetChar(byte character) => MacFarsiTable[character];
+ static char GetChar(byte character) => _macFarsiTable[character];
- ///
- /// Converts a Unicode character to an Mac Farsi character
- ///
+ /// Converts a Unicode character to an Mac Farsi character
/// Mac Farsi character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacGreek.cs b/Claunia.Encoding/MacGreek.cs
index ea09787..289e8f7 100644
--- a/Claunia.Encoding/MacGreek.cs
+++ b/Claunia.Encoding/MacGreek.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Mac Greek character encoding of Unicode characters.
- ///
+ /// Represents an Mac Greek character encoding of Unicode characters.
public class MacGreek : Encoding
{
- const string _bodyname = "x-mac-greek";
- const int _codepage = 10006;
- const string _encodingname = "Greek (Mac)";
- const string _headername = "x-mac-greek";
- const string _webname = "x-mac-greek";
- const int _windowsCodepage = 10006;
+ const string BODY_NAME = "x-mac-greek";
+ const int CODEPAGE = 10006;
+ const string ENCODING_NAME = "Greek (Mac)";
+ const string HEADER_NAME = "x-mac-greek";
+ const string WEB_NAME = "x-mac-greek";
+ const int WINDOWS_CODEPAGE = 10006;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Macintosh Greek to Unicode character map.
- ///
- static readonly char[] MacGreekTable =
+ /// The Macintosh Greek to Unicode character map.
+ static readonly char[] _macGreekTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u00C4', '\u00B9', '\u00B2', '\u00C9', '\u00B3', '\u00D6', '\u00DC', '\u0385',
+
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u0384', '\u00A8', '\u00E7', '\u00E9', '\u00E8',
+
// 0x90
'\u00EA', '\u00EB', '\u00A3', '\u2122', '\u00EE', '\u00EF', '\u2022', '\u00BD',
+
// 0x98
'\u2030', '\u00F4', '\u00F6', '\u00A6', '\u20AC', '\u00F9', '\u00FB', '\u00FC',
+
// 0xA0
'\u2020', '\u0393', '\u0394', '\u0398', '\u039B', '\u039E', '\u03A0', '\u00DF',
+
// 0xA8
'\u00AE', '\u00A9', '\u03A3', '\u03AA', '\u00A7', '\u2260', '\u00B0', '\u00B7',
+
// 0xB0
'\u0391', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u0392', '\u0395', '\u0396',
+
// 0xB8
'\u0397', '\u0399', '\u039A', '\u039C', '\u03A6', '\u03AB', '\u03A8', '\u03A9',
+
// 0xC0
'\u03AC', '\u039D', '\u00AC', '\u039F', '\u03A1', '\u2248', '\u03A4', '\u00AB',
+
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u03A5', '\u03A7', '\u0386', '\u0388', '\u0153',
+
// 0xD0
'\u2013', '\u2015', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u0389',
+
// 0xD8
'\u038A', '\u038C', '\u038E', '\u03AD', '\u03AE', '\u03AF', '\u03CC', '\u038F',
+
// 0xE0
'\u03CD', '\u03B1', '\u03B2', '\u03C8', '\u03B4', '\u03B5', '\u03C6', '\u03B3',
+
// 0xE8
'\u03B7', '\u03B9', '\u03BE', '\u03BA', '\u03BB', '\u03BC', '\u03BD', '\u03BF',
+
// 0xF0
'\u03C0', '\u03CE', '\u03C1', '\u03C3', '\u03C4', '\u03B8', '\u03C9', '\u03C2',
+
// 0xF8
'\u03C7', '\u03C5', '\u03B6', '\u03CA', '\u03CB', '\u0390', '\u03B0', '\u00AD'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Mac Greek character to an Unicode character
- ///
+ /// Converts a Mac Greek character to an Unicode character
/// Unicode character.
/// Mac Greek character.
- static char GetChar(byte character) => MacGreekTable[character];
+ static char GetChar(byte character) => _macGreekTable[character];
- ///
- /// Converts a Unicode character to an Mac Greek character
- ///
+ /// Converts a Unicode character to an Mac Greek character
/// Mac Greek character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacHebrew.cs b/Claunia.Encoding/MacHebrew.cs
index 36d0f6e..bdd6446 100644
--- a/Claunia.Encoding/MacHebrew.cs
+++ b/Claunia.Encoding/MacHebrew.cs
@@ -28,205 +28,211 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Mac Hebrew character encoding of Unicode characters.
- ///
+ /// Represents an Mac Hebrew character encoding of Unicode characters.
public class MacHebrew : Encoding
{
- const string _bodyname = "x-mac-hebrew";
- const int _codepage = 10005;
- const string _encodingname = "Hebrew (Mac)";
- const string _headername = "x-mac-hebrew";
- const string _webname = "x-mac-hebrew";
- const int _windowsCodepage = 10005;
+ const string BODY_NAME = "x-mac-hebrew";
+ const int CODEPAGE = 10005;
+ const string ENCODING_NAME = "Hebrew (Mac)";
+ const string HEADER_NAME = "x-mac-hebrew";
+ const string WEB_NAME = "x-mac-hebrew";
+ const int WINDOWS_CODEPAGE = 10005;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
+
+ /// The Macintosh Hebrew to Unicode character map.
- ///
- /// The Macintosh Hebrew to Unicode character map.
- ///
// TODO: 0x81 => 0x05F2+0x05B7
// TODO: 0xC0 => 0xF86A+0x05DC+0x05B9
// TODO: 0xDE => 0x05B8+0xF87F
- static readonly char[] MacHebrewTable =
+ static readonly char[] _macHebrewTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u00C4', '\u0081', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
+
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
+
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
+
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
+
// 0xA0
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u20AA', '\u0027',
+
// 0xA8
'\u0029', '\u0028', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0xB0
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0xB8
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0xC0
'\uF86A', '\u201E', '\uF89B', '\uF89C', '\uF89D', '\uF89E', '\u05BC', '\uFB4B',
+
// 0xC8
'\uFB35', '\u2026', '\u00A0', '\u05B8', '\u05B7', '\u05B5', '\u05B6', '\u05B4',
+
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\uFB2A', '\uFB2B',
+
// 0xD8
'\u05BF', '\u05B0', '\u05B2', '\u05B1', '\u05BB', '\u05B9', '\u05B8', '\u05B3',
+
// 0xE0
'\u05D0', '\u05D1', '\u05D2', '\u05D3', '\u05D4', '\u05D5', '\u05D6', '\u05D7',
+
// 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'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -236,21 +242,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -259,92 +262,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -353,119 +365,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Mac Hebrew character to an Unicode character
- ///
+ /// Converts a Mac Hebrew character to an Unicode character
/// Unicode character.
/// Mac Hebrew character.
- static char GetChar(byte character) => MacHebrewTable[character];
+ static char GetChar(byte character) => _macHebrewTable[character];
- ///
- /// Converts a Unicode character to an Mac Hebrew character
- ///
+ /// Converts a Unicode character to an Mac Hebrew character
/// Mac Hebrew character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacRoman.cs b/Claunia.Encoding/MacRoman.cs
index 62ea41b..a7c76e5 100644
--- a/Claunia.Encoding/MacRoman.cs
+++ b/Claunia.Encoding/MacRoman.cs
@@ -28,203 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Apple Mac character encoding of Unicode characters.
- ///
+ /// Represents an Apple Mac character encoding of Unicode characters.
public class MacRoman : Encoding
{
- const string _bodyname = "macintosh";
- const int _codepage = 10000;
- const string _encodingname = "Western European (Mac)";
- const string _headername = "macintosh";
- const string _webname = "macintosh";
- const int _windowsCodepage = 10000;
+ const string BODY_NAME = "macintosh";
+ const int CODEPAGE = 10000;
+ const string ENCODING_NAME = "Western European (Mac)";
+ const string HEADER_NAME = "macintosh";
+ const string WEB_NAME = "macintosh";
+ const int WINDOWS_CODEPAGE = 10000;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Mac to Unicode character map.
- /// MacRoman is a superset of LisaRoman.
- ///
- static readonly char[] MacRomanTable =
+ /// The Mac to Unicode character map. MacRoman is a superset of LisaRoman.
+ static readonly char[] _macRomanTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
+
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
+
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
+
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
+
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
+
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8',
+
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211',
+
// 0xB8
'\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8',
+
// 0xC0
'\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
+
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153',
+
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
+
// 0xD8
'\u00FF', '\u0178', '\u2044', '\u20AC', '\u2039', '\u203A', '\uFB01', '\uFB02',
+
// 0xE0
'\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1',
+
// 0xE8
'\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4',
+
// 0xF0
'\uF8FF', '\u00D2', '\u00DA', '\u00DB', '\u00D9', '\u0131', '\u02C6', '\u02DC',
+
// 0xF8
'\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -234,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -257,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -351,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a MacRoman character to an Unicode character
- ///
+ /// Converts a MacRoman character to an Unicode character
/// Unicode character.
/// MacRoman character.
- static char GetChar(byte character) => MacRomanTable[character];
+ static char GetChar(byte character) => _macRomanTable[character];
- ///
- /// Converts a Unicode character to an MacRoman character
- ///
+ /// Converts a Unicode character to an MacRoman character
/// MacRoman character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacRomanian.cs b/Claunia.Encoding/MacRomanian.cs
index 61c3b29..c2f8706 100644
--- a/Claunia.Encoding/MacRomanian.cs
+++ b/Claunia.Encoding/MacRomanian.cs
@@ -28,203 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Apple Mac character encoding of Unicode characters.
- ///
+ /// Represents an Apple Mac character encoding of Unicode characters.
public class MacRomanian : Encoding
{
- const string _bodyname = "x-mac-romanian";
- const int _codepage = 10010;
- const string _encodingname = "Romanianian (Mac)";
- const string _headername = "x-mac-romanian";
- const string _webname = "x-mac-romanian";
- const int _windowsCodepage = 10010;
+ const string BODY_NAME = "x-mac-romanian";
+ const int CODEPAGE = 10010;
+ const string ENCODING_NAME = "Romanianian (Mac)";
+ const string HEADER_NAME = "x-mac-romanian";
+ const string WEB_NAME = "x-mac-romanian";
+ const int WINDOWS_CODEPAGE = 10010;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Mac to Unicode character map.
- /// MacRomanian is a superset of MacRomanian.
- ///
- static readonly char[] MacRomanianTable =
+ /// The Mac to Unicode character map. MacRomanian is a superset of MacRomanian.
+ static readonly char[] _macRomanianTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
+
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
+
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
+
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
+
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
+
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u0102', '\u0218',
+
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211',
+
// 0xB8
'\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u0103', '\u0219',
+
// 0xC0
'\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
+
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153',
+
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
+
// 0xD8
'\u00FF', '\u0178', '\u2044', '\u20AC', '\u2039', '\u203A', '\u021A', '\u021B',
+
// 0xE0
'\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1',
+
// 0xE8
'\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4',
+
// 0xF0
'\uF8FF', '\u00D2', '\u00DA', '\u00DB', '\u00D9', '\u0131', '\u02C6', '\u02DC',
+
// 0xF8
'\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -234,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -257,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -351,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a MacRomanian character to an Unicode character
- ///
+ /// Converts a MacRomanian character to an Unicode character
/// Unicode character.
/// MacRomanian character.
- static char GetChar(byte character) => MacRomanianTable[character];
+ static char GetChar(byte character) => _macRomanianTable[character];
- ///
- /// Converts a Unicode character to an MacRomanian character
- ///
+ /// Converts a Unicode character to an MacRomanian character
/// MacRomanian character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacTurkish.cs b/Claunia.Encoding/MacTurkish.cs
index 47e20c0..0669bdd 100644
--- a/Claunia.Encoding/MacTurkish.cs
+++ b/Claunia.Encoding/MacTurkish.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Mac Turkish character encoding of Unicode characters.
- ///
+ /// Represents an Mac Turkish character encoding of Unicode characters.
public class MacTurkish : Encoding
{
- const string _bodyname = "x-mac-turkish";
- const int _codepage = 10081;
- const string _encodingname = "Turkish (Mac)";
- const string _headername = "x-mac-turkish";
- const string _webname = "x-mac-turkish";
- const int _windowsCodepage = 10081;
+ const string BODY_NAME = "x-mac-turkish";
+ const int CODEPAGE = 10081;
+ const string ENCODING_NAME = "Turkish (Mac)";
+ const string HEADER_NAME = "x-mac-turkish";
+ const string WEB_NAME = "x-mac-turkish";
+ const int WINDOWS_CODEPAGE = 10081;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Macintosh Turkish to Unicode character map.
- ///
- static readonly char[] MacTurkishTable =
+ /// The Macintosh Turkish to Unicode character map.
+ static readonly char[] _macTurkishTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u00C4', '\u00C5', '\u00C7', '\u00C9', '\u00D1', '\u00D6', '\u00DC', '\u00E1',
+
// 0x88
'\u00E0', '\u00E2', '\u00E4', '\u00E3', '\u00E5', '\u00E7', '\u00E9', '\u00E8',
+
// 0x90
'\u00EA', '\u00EB', '\u00ED', '\u00EC', '\u00EE', '\u00EF', '\u00F1', '\u00F3',
+
// 0x98
'\u00F2', '\u00F4', '\u00F6', '\u00F5', '\u00FA', '\u00F9', '\u00FB', '\u00FC',
+
// 0xA0
'\u2020', '\u00B0', '\u00A2', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u00DF',
+
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u00B4', '\u00A8', '\u2260', '\u00C6', '\u00D8',
+
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u00A5', '\u00B5', '\u2202', '\u2211',
+
// 0xB8
'\u220F', '\u03C0', '\u222B', '\u00AA', '\u00BA', '\u03A9', '\u00E6', '\u00F8',
+
// 0xC0
'\u00BF', '\u00A1', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
+
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u00C0', '\u00C3', '\u00D5', '\u0152', '\u0153',
+
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u25CA',
+
// 0xD8
'\u00FF', '\u0178', '\u011E', '\u011F', '\u0130', '\u0131', '\u015E', '\u015F',
+
// 0xE0
'\u2021', '\u00B7', '\u201A', '\u201E', '\u2030', '\u00C2', '\u00CA', '\u00C1',
+
// 0xE8
'\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00D3', '\u00D4',
+
// 0xF0
'\uF8FF', '\u00D2', '\u00DA', '\u00D8', '\u00D9', '\uF8A0', '\u02C6', '\u02DC',
+
// 0xF8
'\u00AF', '\u02D8', '\u02D9', '\u02DA', '\u00B8', '\u02DD', '\u02DB', '\u02C7'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Mac Turkish character to an Unicode character
- ///
+ /// Converts a Mac Turkish character to an Unicode character
/// Unicode character.
/// Mac Turkish character.
- static char GetChar(byte character) => MacTurkishTable[character];
+ static char GetChar(byte character) => _macTurkishTable[character];
- ///
- /// Converts a Unicode character to an Mac Turkish character
- ///
+ /// Converts a Unicode character to an Mac Turkish character
/// Mac Turkish character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/MacUkrainian.cs b/Claunia.Encoding/MacUkrainian.cs
index b5bf035..b442a5d 100644
--- a/Claunia.Encoding/MacUkrainian.cs
+++ b/Claunia.Encoding/MacUkrainian.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Mac Ukrainian character encoding of Unicode characters.
- ///
+ /// Represents an Mac Ukrainian character encoding of Unicode characters.
public class MacUkrainian : Encoding
{
- const string _bodyname = "x-mac-ukrainian";
- const int _codepage = 10017;
- const string _encodingname = "Ukrainian (Mac)";
- const string _headername = "x-mac-ukrainian";
- const string _webname = "x-mac-ukrainian";
- const int _windowsCodepage = 10017;
+ const string BODY_NAME = "x-mac-ukrainian";
+ const int CODEPAGE = 10017;
+ const string ENCODING_NAME = "Ukrainian (Mac)";
+ const string HEADER_NAME = "x-mac-ukrainian";
+ const string WEB_NAME = "x-mac-ukrainian";
+ const int WINDOWS_CODEPAGE = 10017;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = true;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = true;
+ const bool SINGLE_BYTE = true;
- ///
- /// The Macintosh Ukrainian to Unicode character map.
- ///
- static readonly char[] MacUkrainianTable =
+ /// The Macintosh Ukrainian to Unicode character map.
+ static readonly char[] _macUkrainianTable =
{
// 0x00
'\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007',
+
// 0x08
'\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F',
+
// 0x10
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
+
// 0x18
'\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
+
// 0x60
'\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u007F',
+
// 0x80
'\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416', '\u0417',
+
// 0x88
'\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D', '\u041E', '\u041F',
+
// 0x90
'\u0420', '\u0421', '\u0422', '\u0423', '\u0424', '\u0425', '\u0426', '\u0427',
+
// 0x98
'\u0428', '\u0429', '\u042A', '\u042B', '\u042C', '\u042D', '\u042E', '\u042F',
+
// 0xA0
'\u2020', '\u00B0', '\u0490', '\u00A3', '\u00A7', '\u2022', '\u00B6', '\u0406',
+
// 0xA8
'\u00AE', '\u00A9', '\u2122', '\u0402', '\u0452', '\u2260', '\u0403', '\u0453',
+
// 0xB0
'\u221E', '\u00B1', '\u2264', '\u2265', '\u0456', '\u00B5', '\u0491', '\u0408',
+
// 0xB8
'\u0404', '\u0454', '\u0407', '\u0457', '\u0409', '\u0459', '\u040A', '\u045A',
+
// 0xC0
'\u0458', '\u0405', '\u00AC', '\u221A', '\u0192', '\u2248', '\u2206', '\u00AB',
+
// 0xC8
'\u00BB', '\u2026', '\u00A0', '\u040B', '\u045B', '\u040C', '\u045C', '\u0455',
+
// 0xD0
'\u2013', '\u2014', '\u201C', '\u201D', '\u2018', '\u2019', '\u00F7', '\u201E',
+
// 0xD8
'\u040E', '\u045E', '\u040F', '\u045F', '\u2116', '\u0401', '\u0451', '\u044F',
+
// 0xE0
'\u0430', '\u0431', '\u0432', '\u0433', '\u0434', '\u0435', '\u0436', '\u0437',
+
// 0xE8
'\u0438', '\u0439', '\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F',
+
// 0xF0
'\u0440', '\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447',
+
// 0xF8
'\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E', '\u20AC'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Mac Ukrainian character to an Unicode character
- ///
+ /// Converts a Mac Ukrainian character to an Unicode character
/// Unicode character.
/// Mac Ukrainian character.
- static char GetChar(byte character) => MacUkrainianTable[character];
+ static char GetChar(byte character) => _macUkrainianTable[character];
- ///
- /// Converts a Unicode character to an Mac Ukrainian character
- ///
+ /// Converts a Unicode character to an Mac Ukrainian character
/// Mac Ukrainian character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/PETSCII.cs b/Claunia.Encoding/PETSCII.cs
index 13fc20d..ee3087c 100644
--- a/Claunia.Encoding/PETSCII.cs
+++ b/Claunia.Encoding/PETSCII.cs
@@ -29,202 +29,209 @@ using System;
namespace Claunia.Encoding
{
///
- /// Represents an Commodore PET Standard Code for Information Interchange (aka CBM ASCII) character encoding of Unicode
- /// characters.
+ /// Represents an Commodore PET Standard Code for Information Interchange (aka CBM ASCII) character encoding of
+ /// Unicode characters.
///
- public class PETSCII : Encoding
+ public class Petscii : Encoding
{
- const string _bodyname = "petscii";
- const int _codepage = 0;
- const string _encodingname = "Commodore PET Standard Code for Information Interchange";
- const string _headername = "petscii";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "petscii";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Commodore PET Standard Code for Information Interchange";
+ const string HEADER_NAME = "petscii";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = true;
- ///
- /// The PETSCII to Unicode character map, unshifted (default) variant.
- ///
+ /// The PETSCII to Unicode character map, unshifted (default) variant.
/// Reference used: http://style64.org/petscii/ and others.
- static readonly char[] PETSCIITable =
+ static readonly char[] _petsciiTable =
{
// 0x00
'\u0000', '\u0000', '\u0000', '\u0003', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x08
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u000A', '\u0000', '\u0000',
+
// 0x10
'\u0000', '\u0000', '\u0000', '\u0000', '\u0008', '\u0000', '\u0000', '\u0000',
+
// 0x18
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u00A3', '\u005D', '\u2191', '\u2190',
+
// 0x60
'\u2500', '\u2660', '\u2502', '\u2500', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x68
'\u0000', '\u256E', '\u2570', '\u256F', '\u0000', '\u2572', '\u2571', '\u0000',
+
// 0x70
'\u0000', '\u2022', '\u0000', '\u2665', '\u0000', '\u256D', '\u2573', '\u25CB',
+
// 0x78
'\u2663', '\u0000', '\u2666', '\u253C', '\u0000', '\u2502', '\u03C0', '\u25E5',
+
// 0x80
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x88
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u2028', '\u0000', '\u0000',
+
// 0x90
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x98
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xA0
'\u00A0', '\u258C', '\u2584', '\u2594', '\u2581', '\u258E', '\u2592', '\u0000',
+
// 0xA8
'\u0000', '\u25E4', '\u258A', '\u251C', '\u2597', '\u2514', '\u2510', '\u2582',
+
// 0xB0
'\u250C', '\u2534', '\u252C', '\u2524', '\u258E', '\u258D', '\u0000', '\u0000',
+
// 0xB8
'\u0000', '\u2583', '\u0000', '\u2596', '\u259D', '\u2518', '\u2598', '\u259A',
+
// 0xC0 (repeats 0x60 - 0x67)
'\u2500', '\u2660', '\u2502', '\u2500', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xC8 (repeats 0x68 - 0x6F)
'\u0000', '\u256E', '\u2570', '\u256F', '\u0000', '\u2572', '\u2571', '\u0000',
+
// 0xD0 (repeats 0x70 - 0x77)
'\u0000', '\u2022', '\u0000', '\u2665', '\u0000', '\u256D', '\u2573', '\u25CB',
+
// 0xD8 (repeats 0x78 - 0x7F)
'\u2663', '\u0000', '\u2666', '\u253C', '\u0000', '\u2502', '\u03C0', '\u25E5',
+
// 0xE0 (repeats 0xA0 - 0xA7)
'\u00A0', '\u258C', '\u2584', '\u2594', '\u2581', '\u258E', '\u2592', '\u0000',
+
// 0xE8 (repeats 0xA8 - 0xAF)
'\u0000', '\u25E4', '\u258A', '\u251C', '\u2597', '\u2514', '\u2510', '\u2582',
+
// 0xF0 (repeats 0xB0 - 0xB7)
'\u250C', '\u2534', '\u252C', '\u2524', '\u258E', '\u258D', '\u0000', '\u0000',
+
// 0xF8 (repeats 0xB8 - 0xBF)
'\u0000', '\u2583', '\u0000', '\u2596', '\u259D', '\u2518', '\u2598', '\u259A'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
+ /// Gets a value indicating whether the current encoding is read-only.
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
- public override bool IsReadOnly => readOnly;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
-
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -234,21 +241,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -257,92 +261,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -351,128 +364,128 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a PETSCII character to an Unicode character
- ///
+ /// Converts a PETSCII character to an Unicode character
/// Unicode character.
/// PETSCII character.
- static char GetChar(byte character) => PETSCIITable[character];
+ static char GetChar(byte character) => _petsciiTable[character];
- ///
- /// Converts a Unicode character to an PETSCII character
- ///
+ /// Converts a Unicode character to an PETSCII character
/// PETSCII character.
/// Unicode character.
static byte GetByte(char character)
{
- if(character == 0x0000) return 0x3F;
+ if(character == 0x0000)
+ return 0x3F;
for(int i = 0; i < 256; i++)
+
// TODO: convert this to a gigantic switch statement too?
- if(PETSCIITable[i] == character)
+ if(_petsciiTable[i] == character)
return (byte)i;
// Fallback to '?'
diff --git a/Claunia.Encoding/Pangrams.cs b/Claunia.Encoding/Pangrams.cs
index 863d30e..65327ce 100644
--- a/Claunia.Encoding/Pangrams.cs
+++ b/Claunia.Encoding/Pangrams.cs
@@ -26,110 +26,108 @@
namespace Claunia.Encoding
{
- ///
- /// Class containing pangrams for several languages that can be used to test encoding.
- ///
+ /// 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 =
+ 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.";
+ 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";
+ 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 =
+ 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 = "Хълцащ змей плюе шофьор стигнал чуждия бивак.";
+ public const string BULGARIAN = "Хълцащ змей плюе шофьор стигнал чуждия бивак.";
/// A pangram that contains all (or most) Catalan characters.
- public const string Catalan =
+ 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 ChineseTraditional = "視野無限廣,窗外有藍天";
+ public const string CHINESE_TRADITIONAL = "視野無限廣,窗外有藍天";
/// A pangram that contains Simplified Chinese characters.
- public const string ChineseSimplified = "Innovation in China 中国智造,慧及全球";
+ 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.";
+ 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 =
+ 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 =
+ 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.";
+ 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.";
+ 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.";
+ 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.";
+ 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 =
+ 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 =
+ 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 =
+ 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.";
+ 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 =
+ 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 =
+ 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.";
+ 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.";
+ 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";
+ 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 JapaneseKanji = "色は匂へど 散りぬるを 我が世誰ぞ 常ならむ 有為の奥山 今日越えて 浅き夢見じ 酔ひもせず(ん)";
+ public const string JAPANESE = "いろはにほへと ちりぬるを わかよたれそ つねならむ うゐのおくやま けふこえて あさきゆめみし ゑひもせす(ん)";
+ /// using Kanjis
+ public const string JAPANESE_KANJI = "色は匂へど 散りぬるを 我が世誰ぞ 常ならむ 有為の奥山 今日越えて 浅き夢見じ 酔ひもせず(ん)";
/// A pangram that contains all (or most) Korean characters.
- public const string Korean = "키스의 고유조건은 입술끼리 만나야 하고 특별한 기술은 필요치 않다";
+ 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.";
+ 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ą";
+ 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 = "Ѕидарски пејзаж: шугав билмез со чудење џвака ќофте и кељ на туѓ цех.";
+ 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";
+ 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!";
+ 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 =
+ 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.";
+ 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 =
+ 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.";
+ 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.";
+ 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 =
+ 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.";
+ 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 =
+ 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.";
+ 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.";
+ 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.";
+ 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 5ce722d..6b67712 100644
--- a/Claunia.Encoding/Radix50.cs
+++ b/Claunia.Encoding/Radix50.cs
@@ -28,154 +28,135 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an Radix-50 (PDP-11) character encoding of Unicode characters.
- ///
+ /// Represents an Radix-50 (PDP-11) character encoding of Unicode characters.
public class Radix50 : Encoding
{
- const string _bodyname = "radix50";
- const int _codepage = 0;
- const string _encodingname = "Western European (Radix-50)";
- const string _headername = "radix50";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "radix50";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Western European (Radix-50)";
+ const string HEADER_NAME = "radix50";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = false;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = false;
- ///
- /// The Radix-50 to Unicode character map, when bits are shifted right
- ///
- static readonly char[] Radix50Table =
+ /// The Radix-50 to Unicode character map, when bits are shifted right
+ static readonly char[] _radix50Table =
{
// 0x00
'\u0020', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x08
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x10
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x18
'\u0058', '\u0059', '\u005A', '\u0024', '\u002E', '\u0025', '\u0030', '\u0031',
+
// 0x20
'\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', '\u0038', '\u0039',
+
// 0x28 (unused but legal)
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x30 (unused but legal)
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x38 (unused but legal)
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ if(s == null)
+ throw new ArgumentNullException(nameof(s));
- return s.Length * 6 % 8 > 0 ? s.Length * 6 / 8 + 1 : s.Length * 6 / 8;
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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;
+ 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- return chars.Length * 6 % 8 > 0 ? chars.Length * 6 / 8 + 1 : chars.Length * 6 / 8;
+ return chars.Length * 6 % 8 > 0 ? (chars.Length * 6 / 8) + 1 : chars.Length * 6 / 8;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -185,21 +166,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -208,49 +186,61 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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];
+ 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++)
@@ -260,27 +250,35 @@ namespace Claunia.Encoding
switch(i % 4)
{
case 0:
- if(outPos >= bytes.Length) break;
+ if(outPos >= bytes.Length)
+ break;
bytes[outPos] = (byte)(thisByte << 2);
+
break;
case 1:
- if(outPos + 1 >= bytes.Length) break;
+ 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;
+ 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;
+ if(outPos + 2 >= bytes.Length)
+ break;
bytes[outPos + 2] += (byte)(thisByte & 0x3F);
outPos += 3;
+
break;
}
}
@@ -288,43 +286,39 @@ namespace Claunia.Encoding
return bytes;
}
- ///
- /// Encodes all the characters in the specified character array into a sequence of 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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 the specified character array.
- ///
+ /// 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.
@@ -333,81 +327,95 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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;
+ 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;
}
}
@@ -415,63 +423,50 @@ namespace Claunia.Encoding
return chars;
}
- ///
- /// Calculates the maximum number of bytes produced by encoding the specified number of characters.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- return charCount * 6 % 8 > 0 ? charCount * 6 / 8 + 1 : charCount * 6 / 8;
+ 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.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount * 8 / 6;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a Apple II character to an Unicode character
- ///
+ /// Converts a Apple II character to an Unicode character
/// Unicode character.
/// Apple II character.
- static char GetChar(byte character) => Radix50Table[character & 0x3F];
+ static char GetChar(byte character) => _radix50Table[character & 0x3F];
- ///
- /// Converts a Unicode character to an Apple II character
- ///
+ /// Converts a Unicode character to an Apple II character
/// Apple II character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/ZX80.cs b/Claunia.Encoding/ZX80.cs
index 540e5dd..1b6a8f9 100644
--- a/Claunia.Encoding/ZX80.cs
+++ b/Claunia.Encoding/ZX80.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents a ZX80 character encoding of Unicode characters.
- ///
- public class ZX80 : Encoding
+ /// Represents a ZX80 character encoding of Unicode characters.
+ public class Zx80 : Encoding
{
- const string _bodyname = "zx80";
- const int _codepage = 0;
- const string _encodingname = "Sinclair ZX80 character set";
- const string _headername = "zx80";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "zx80";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Sinclair ZX80 character set";
+ const string HEADER_NAME = "zx80";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = true;
- ///
- /// The ZX80 to Unicode character map.
- ///
- static readonly char[] ZX80Table =
+ /// The ZX80 to Unicode character map.
+ static readonly char[] _zx80Table =
{
// 0x00
'\u0020', '\u0022', '\u258C', '\u2584', '\u2598', '\u259D', '\u2596', '\u2597',
+
// 0x08
'\u259E', '\u2592', '\uFFFD', '\uFFFD', '\u00A3', '\u0024', '\u003A', '\u003F',
+
// 0x10
'\u0028', '\u0029', '\u002D', '\u002B', '\u002A', '\u002F', '\u003D', '\u003E',
+
// 0x18
'\u003C', '\u003B', '\u002C', '\u002E', '\u0030', '\u0031', '\u0032', '\u0033',
+
// 0x20
'\u0034', '\u0035', '\u0036', '\u0037', '\u0038', '\u0039', '\u0041', '\u0042',
+
// 0x28
'\u0043', '\u0044', '\u0045', '\u0046', '\u0047', '\u0048', '\u0049', '\u004A',
+
// 0x30
'\u004B', '\u004C', '\u004D', '\u004E', '\u004F', '\u0050', '\u0051', '\u0052',
+
// 0x38
'\u0053', '\u0054', '\u0055', '\u0056', '\u0057', '\u0058', '\u0059', '\u005A',
+
// 0x40
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x48
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x50
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x58
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x60
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x68
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x70
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u000D', '\uFFFD', '\u000A', '\u0008',
+
// 0x78
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x80
'\u2588', '\uFFFD', '\u2590', '\u2580', '\u2599', '\u259C', '\u259B', '\u259A',
+
// 0x88
'\u2592', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0x90
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0x98
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xA0
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xA8
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xB0
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xB8
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xC0
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xC8
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0xD0
'\u0000', '\u0000', '\u0000', '\u0000', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xD8
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xE0
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xE8
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xF0
'\uFFFF', '\u0000', '\u0000', '\uFFFF', '\uFFFF', '\u0000', '\uFFFF', '\uFFFF',
+
// 0xF8
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u0000'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a ZX80 character to an Unicode character
- ///
+ /// Converts a ZX80 character to an Unicode character
/// Unicode character.
/// ZX80 character.
- static char GetChar(byte character) => ZX80Table[character];
+ static char GetChar(byte character) => _zx80Table[character];
- ///
- /// Converts a Unicode character to an ZX80 character
- ///
+ /// Converts a Unicode character to an ZX80 character
/// ZX80 character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/ZX81.cs b/Claunia.Encoding/ZX81.cs
index 72e5602..5bb4978 100644
--- a/Claunia.Encoding/ZX81.cs
+++ b/Claunia.Encoding/ZX81.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents a ZX81 character encoding of Unicode characters.
- ///
- public class ZX81 : Encoding
+ /// Represents a ZX81 character encoding of Unicode characters.
+ public class Zx81 : Encoding
{
- const string _bodyname = "zx81";
- const int _codepage = 0;
- const string _encodingname = "Sinclair ZX81 character set";
- const string _headername = "zx81";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "zx81";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Sinclair ZX81 character set";
+ const string HEADER_NAME = "zx81";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = true;
- ///
- /// The ZX81 to Unicode character map.
- ///
- static readonly char[] ZX81Table =
+ /// The ZX81 to Unicode character map.
+ static readonly char[] _zx81Table =
{
// 0x00
'\u0020', '\u2598', '\u259D', '\u2580', '\u2596', '\u258C', '\u259E', '\u259B',
+
// 0x08
'\u2592', '\uFFFD', '\uFFFD', '\u0022', '\u00A3', '\u0024', '\u003A', '\u003F',
+
// 0x10
'\u0028', '\u0029', '\u003E', '\u003C', '\u003D', '\u002B', '\u002D', '\u002A',
+
// 0x18
'\u002F', '\u003B', '\u002C', '\u002E', '\u0030', '\u0031', '\u0032', '\u0033',
+
// 0x20
'\u0034', '\u0035', '\u0036', '\u0037', '\u0038', '\u0039', '\u0041', '\u0042',
+
// 0x28
'\u0043', '\u0044', '\u0045', '\u0046', '\u0047', '\u0048', '\u0049', '\u004A',
+
// 0x30
'\u004B', '\u004C', '\u004D', '\u004E', '\u004F', '\u0050', '\u0051', '\u0052',
+
// 0x38
'\u0053', '\u0054', '\u0055', '\u0056', '\u0057', '\u0058', '\u0059', '\u005A',
+
// 0x40
'\uFFFF', '\uFFFF', '\uFFFF', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x48
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x50
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x58
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x60
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x68
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x70
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u000A', '\u0008',
+
// 0x78
'\uFFFF', '\uFFFF', '\u0000', '\u0000', '\u0000', '\u0000', '\uFFFF', '\uFFFF',
+
// 0x80
'\u2588', '\u259F', '\u2599', '\u2584', '\u259C', '\u2590', '\u259A', '\u2597',
+
// 0x88
'\u2592', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0x90
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0x98
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xA0
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xA8
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xB0
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xB8
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xC0
'\uFFFF', '\uFFFF', '\uFFFF', '\u0000', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xC8
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xD0
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xD8
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xE0
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xE8
'\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'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a ZX81 character to an Unicode character
- ///
+ /// Converts a ZX81 character to an Unicode character
/// Unicode character.
/// ZX81 character.
- static char GetChar(byte character) => ZX81Table[character];
+ static char GetChar(byte character) => _zx81Table[character];
- ///
- /// Converts a Unicode character to an ZX81 character
- ///
+ /// Converts a Unicode character to an ZX81 character
/// ZX81 character.
/// Unicode character.
static byte GetByte(char character)
diff --git a/Claunia.Encoding/ZXSpectrum.cs b/Claunia.Encoding/ZXSpectrum.cs
index 8efc20c..f36a967 100644
--- a/Claunia.Encoding/ZXSpectrum.cs
+++ b/Claunia.Encoding/ZXSpectrum.cs
@@ -28,202 +28,207 @@ using System;
namespace Claunia.Encoding
{
- ///
- /// Represents an ZX Spectrum character encoding of Unicode characters.
- ///
- public class ZXSpectrum : Encoding
+ /// Represents an ZX Spectrum character encoding of Unicode characters.
+ public class ZxSpectrum : Encoding
{
- const string _bodyname = "spectrum";
- const int _codepage = 0;
- const string _encodingname = "Sinclair ZX Spectrum character set";
- const string _headername = "spectrum";
- const string _webname = "";
- const int _windowsCodepage = 0;
+ const string BODY_NAME = "spectrum";
+ const int CODEPAGE = 0;
+ const string ENCODING_NAME = "Sinclair ZX Spectrum character set";
+ const string HEADER_NAME = "spectrum";
+ const string WEB_NAME = "";
+ const int WINDOWS_CODEPAGE = 0;
- const bool browserDisplay = false;
- const bool browserSave = false;
- const bool mailNewsDisplay = false;
- const bool mailNewsSave = false;
- const bool readOnly = false;
- const bool singleByte = true;
+ const bool BROWSER_DISPLAY = false;
+ const bool BROWSER_SAVE = false;
+ const bool MAIL_NEWS_DISPLAY = false;
+ const bool MAIL_NEWS_SAVE = false;
+ const bool READ_ONLY = false;
+ const bool SINGLE_BYTE = true;
- ///
- /// The ZX Spectrum to Unicode character map.
- ///
- static readonly char[] ZXSpectrumTable =
+ /// The ZX Spectrum to Unicode character map.
+ static readonly char[] _zxSpectrumTable =
{
// 0x00
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0009', '\u0000',
+
// 0x08
'\uFFFF', '\uFFFF', '\u0000', '\u0000', '\u0000', '\u000D', '\uFFFF', '\u0000',
+
// 0x10
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\u0009',
+
// 0x18
'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000',
+
// 0x20
'\u0020', '\u0021', '\u0022', '\u0023', '\u0024', '\u0025', '\u0026', '\u0027',
+
// 0x28
'\u0028', '\u0029', '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
+
// 0x30
'\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037',
+
// 0x38
'\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', '\u003F',
+
// 0x40
'\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
+
// 0x48
'\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D', '\u004E', '\u004F',
+
// 0x50
'\u0050', '\u0051', '\u0052', '\u0053', '\u0054', '\u0055', '\u0056', '\u0057',
+
// 0x58
'\u0058', '\u0059', '\u005A', '\u005B', '\u005C', '\u005D', '\u2191', '\u005F',
+
// 0x60
'\u00A3', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067',
+
// 0x68
'\u0068', '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F',
+
// 0x70
'\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
+
// 0x78
'\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', '\u007E', '\u00A9',
+
// 0x80
'\u0020', '\u259D', '\u2598', '\u2580', '\u2597', '\u2590', '\u259A', '\u259C',
+
// 0x88
'\u2596', '\u259E', '\u258C', '\u259B', '\u2584', '\u259F', '\u2599', '\u2588',
+
// 0x90
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0x98
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD',
+
// 0xA0
'\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFD', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xA8
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xB0
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xB8
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xC0
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xC8
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xD0
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xD8
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xE0
'\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF', '\uFFFF',
+
// 0xE8
'\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'
};
- ///
- /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
- ///
- public override bool IsBrowserDisplay => browserDisplay;
+ /// Gets a value indicating whether the current encoding can be used by browser clients for displaying content.
+ public override bool IsBrowserDisplay => BROWSER_DISPLAY;
+
+ /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ public override bool IsBrowserSave => BROWSER_SAVE;
///
- /// Gets a value indicating whether the current encoding can be used by browser clients for saving content.
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying
+ /// content.
///
- public override bool IsBrowserSave => browserSave;
+ public override bool IsMailNewsDisplay => MAIL_NEWS_DISPLAY;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for displaying content.
- ///
- public override bool IsMailNewsDisplay => mailNewsDisplay;
+ /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
+ public override bool IsMailNewsSave => MAIL_NEWS_SAVE;
- ///
- /// Gets a value indicating whether the current encoding can be used by mail and news clients for saving content.
- ///
- public override bool IsMailNewsSave => mailNewsSave;
-
- ///
- /// Gets a value indicating whether the current encoding is read-only.
- ///
+ /// Gets a value indicating whether the current encoding is read-only.
/// The is single byte.
- public override bool IsReadOnly => readOnly;
+ public override bool IsReadOnly => READ_ONLY;
- ///
- /// Gets a value indicating whether the current encoding uses single-byte code points.
- ///
- public override bool IsSingleByte => singleByte;
+ /// Gets a value indicating whether the current encoding uses single-byte code points.
+ public override bool IsSingleByte => SINGLE_BYTE;
- ///
- /// Gets the code page identifier of the current Encoding.
- ///
- public override int CodePage => _codepage;
+ /// Gets the code page identifier of the current Encoding.
+ public override int CodePage => CODEPAGE;
- ///
- /// Gets a name for the current encoding that can be used with mail agent body tags
- ///
- public override string BodyName => _bodyname;
+ /// Gets a name for the current encoding that can be used with mail agent body tags
+ public override string BodyName => BODY_NAME;
- ///
- /// Gets a name for the current encoding that can be used with mail agent header tags
- ///
- public override string HeaderName => _headername;
+ /// Gets a name for the current encoding that can be used with mail agent header tags
+ public override string HeaderName => HEADER_NAME;
- ///
- /// Ggets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
- ///
- public override string WebName => _webname;
+ /// Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the current encoding.
+ public override string WebName => WEB_NAME;
- ///
- /// Gets the human-readable description of the current encoding.
- ///
- public override string EncodingName => _encodingname;
+ /// Gets the human-readable description of the current encoding.
+ public override string EncodingName => ENCODING_NAME;
- ///
- /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
- ///
- public override int WindowsCodePage => _windowsCodepage;
+ /// Gets the Windows operating system code page that most closely corresponds to the current encoding.
+ public override int WindowsCodePage => WINDOWS_CODEPAGE;
- ///
- /// Calculates the number of bytes produced by encoding the characters in the specified .
- ///
+ /// 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));
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0 || index >= chars.Length) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0 ||
+ index >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0 || index + count > 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.
- ///
+ /// 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));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
return chars.Length;
}
- ///
- /// Encodes a set of characters from the specified into the specified byte array.
- ///
+ /// 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.
@@ -233,21 +238,18 @@ namespace Claunia.Encoding
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.
- ///
+ /// 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));
+ 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.
- ///
+ /// 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.
@@ -256,92 +258,101 @@ namespace Claunia.Encoding
/// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(bytes == null) throw new ArgumentNullException(nameof(bytes));
+ if(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charCount + charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charCount));
+ if(charCount + charIndex > chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteIndex + charCount > bytes.Length) throw new ArgumentException(nameof(bytes));
+ 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];
+ 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.
- ///
+ /// 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(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > chars.Length) 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]);
+ 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.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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.
- ///
+ /// 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.
@@ -350,119 +361,117 @@ namespace Claunia.Encoding
/// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(chars == null) throw new ArgumentNullException(nameof(chars));
+ if(chars == null)
+ throw new ArgumentNullException(nameof(chars));
- if(byteIndex < 0) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex < 0) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex < 0)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(byteIndex >= bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex));
+ if(byteIndex >= bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteIndex));
- if(byteCount + byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteCount));
+ if(byteCount + byteIndex > bytes.Length)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
- if(charIndex >= chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex));
+ if(charIndex >= chars.Length)
+ throw new ArgumentOutOfRangeException(nameof(charIndex));
- if(charIndex + byteCount > chars.Length) throw new ArgumentException(nameof(chars));
+ 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];
+ 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.
- ///
+ /// 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.
- ///
+ /// 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(bytes == null)
+ throw new ArgumentNullException(nameof(bytes));
- if(index < 0) throw new ArgumentOutOfRangeException(nameof(index));
+ if(index < 0)
+ throw new ArgumentOutOfRangeException(nameof(index));
- if(count < 0) throw new ArgumentOutOfRangeException(nameof(count));
+ if(count < 0)
+ throw new ArgumentOutOfRangeException(nameof(count));
- if(count + index > bytes.Length) 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]);
+ 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.
- ///
+ /// 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));
+ if(charCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(charCount));
return charCount;
}
- ///
- /// Calculates the maximum number of characters produced by decoding the specified number of bytes.
- ///
+ /// 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));
+ if(byteCount < 0)
+ throw new ArgumentOutOfRangeException(nameof(byteCount));
return byteCount;
}
- ///
- /// Returns a sequence of bytes that specifies the encoding used.
- ///
+ /// 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.
- ///
+ /// 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.
- ///
+ /// 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 string(GetChars(bytes, index, count));
+ public override string GetString(byte[] bytes, int index, int count) => new(GetChars(bytes, index, count));
- ///
- /// Converts a ZX Spectrum character to an Unicode character
- ///
+ /// Converts a ZX Spectrum character to an Unicode character
/// Unicode character.
/// ZX Spectrum character.
- static char GetChar(byte character) => ZXSpectrumTable[character];
+ static char GetChar(byte character) => _zxSpectrumTable[character];
- ///
- /// Converts a Unicode character to an ZX Spectrum character
- ///
+ /// Converts a Unicode character to an ZX Spectrum character
/// ZX Spectrum character.
/// Unicode character.
static byte GetByte(char character)