General refactor.

This commit is contained in:
2018-03-07 18:56:12 +00:00
parent e9f4aae440
commit 967687dfd1
33 changed files with 637 additions and 587 deletions

View File

@@ -32,45 +32,46 @@ namespace Claunia.Encoding.Tests
public class ATASCII public class ATASCII
{ {
const string Punctuations = "!\"#$%&'()*+,-./:;<=>?@[\\]^_|"; 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, readonly byte[] PunctuationsBytes =
0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7C }; {
const string Digits = "0123456789"; 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C,
readonly byte[] DigitsBytes = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 }; 0x3D, 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7C
const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; };
readonly byte[] UpperLatinBytes = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, const string Digits = "0123456789";
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A }; readonly byte[] DigitsBytes = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};
const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly byte[] UpperLatinBytes =
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A
};
const string LowerLatin = "abcdefghijklmnopqrstuvwxyz"; const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
readonly byte[] LowerLatinBytes = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, readonly byte[] LowerLatinBytes =
0x75, 0x76, 0x77, 0x78, 0x79, 0x7A }; {
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 = "├┘┤┐╱╲◢▗◣▝▘▂▖┌─┼●▄▎┬┴▌└"; 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, readonly byte[] GraphicsBytes =
0x18, 0x19, 0x1A}; {
const string Arrows = "↑↓←→↰◀▶"; 0x01, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0E, 0x0F, 0x11, 0x12, 0x13, 0x14, 0x15,
readonly byte[] ArrowsBytes = { 0x1C, 0x1D, 0x1E, 0x1F, 0x7D, 0x7E, 0x7F }; 0x16, 0x17, 0x18, 0x19, 0x1A
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] [Test]
public void UnicodeToAtari() public void AtariPangrams()
{ {
byte[] byteArray; byte[] byteArray;
string testString;
byteArray = Encoding.AtariEncoding.GetBytes(Punctuations); byteArray = Encoding.AtariEncoding.GetBytes(Pangrams.English);
Assert.AreEqual(PunctuationsBytes, byteArray); testString = Encoding.AtariEncoding.GetString(byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(Digits); Assert.AreEqual(Pangrams.English, testString);
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(Graphics);
Assert.AreEqual(GraphicsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(Arrows);
Assert.AreEqual(ArrowsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(Decks);
Assert.AreEqual(DecksBytes, byteArray);
} }
[Test] [Test]
@@ -96,14 +97,25 @@ namespace Claunia.Encoding.Tests
} }
[Test] [Test]
public void AtariPangrams() public void UnicodeToAtari()
{ {
byte[] byteArray; byte[] byteArray;
string testString;
byteArray = Encoding.AtariEncoding.GetBytes(Pangrams.English); byteArray = Encoding.AtariEncoding.GetBytes(Punctuations);
testString = Encoding.AtariEncoding.GetString(byteArray); Assert.AreEqual(PunctuationsBytes, byteArray);
Assert.AreEqual(Pangrams.English, testString); 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(Graphics);
Assert.AreEqual(GraphicsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(Arrows);
Assert.AreEqual(ArrowsBytes, byteArray);
byteArray = Encoding.AtariEncoding.GetBytes(Decks);
Assert.AreEqual(DecksBytes, byteArray);
} }
} }
} }

View File

@@ -25,7 +25,6 @@
// THE SOFTWARE. // THE SOFTWARE.
using NUnit.Framework; using NUnit.Framework;
using System.Runtime.InteropServices;
namespace Claunia.Encoding.Tests namespace Claunia.Encoding.Tests
{ {
@@ -33,44 +32,153 @@ namespace Claunia.Encoding.Tests
public class AtariST public class AtariST
{ {
const string Punctuations = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; 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, readonly byte[] PunctuationsBytes =
0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x7B, 0x7C, 0x7D, 0x7E }; {
const string Digits = "0123456789"; 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C,
readonly byte[] DigitsBytes = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 }; 0x3D, 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x7B, 0x7C, 0x7D, 0x7E
const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; };
readonly byte[] UpperLatinBytes = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, const string Digits = "0123456789";
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A }; readonly byte[] DigitsBytes = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};
const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly byte[] UpperLatinBytes =
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A
};
const string LowerLatin = "abcdefghijklmnopqrstuvwxyz"; const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
readonly byte[] LowerLatinBytes = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, readonly byte[] LowerLatinBytes =
0x75, 0x76, 0x77, 0x78, 0x79, 0x7A }; {
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 = "¡¿áéíóúüñÉÜÑ"; const string Spanish = "¡¿áéíóúüñÉÜÑ";
readonly byte[] SpanishBytes = { 0xAD, 0xA8, 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x81, 0xA4, 0x90, 0x9A, 0xA5 }; readonly byte[] SpanishBytes = {0xAD, 0xA8, 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x81, 0xA4, 0x90, 0x9A, 0xA5};
const string French = "éÉàèùÀâêîôûëïüÿçÇœŒæÆ"; 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 }; readonly byte[] FrenchBytes =
const string German = "äöüßÄÖÜ"; {
readonly byte[] GermanBytes = { 0x84, 0x94, 0x81, 0x9E, 0x8E, 0x99, 0x9A }; 0x82, 0x90, 0x85, 0x8A, 0x97, 0xB6, 0x83, 0x88, 0x8C, 0x93, 0x96, 0x89, 0x8B, 0x81, 0x98, 0x87, 0x80, 0xB4,
const string Norwegian = "æøåÆØÅ"; 0xB5, 0x91, 0x92
readonly byte[] NorwegianBytes = { 0x91, 0xB3, 0x86, 0x92, 0xB2, 0x8F }; };
const string Portuguese = "áéíóúÉâêôãõÃÕçÇ"; const string German = "äöüßÄÖÜ";
readonly byte[] PortugueseBytes = { 0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x90, 0x83, 0x88, 0x93, 0xB0, 0xB1, 0xB7, 0xB8, 0x87, 0x80 }; readonly byte[] GermanBytes = {0x84, 0x94, 0x81, 0x9E, 0x8E, 0x99, 0x9A};
const string Dutch = "ijIJ"; const string Norwegian = "æøåÆØÅ";
readonly byte[] DutchBytes = { 0xC0, 0xC1 }; readonly byte[] NorwegianBytes = {0x91, 0xB3, 0x86, 0x92, 0xB2, 0x8F};
const string Hebrew = "אבגדהוזחטיכלמנסעפצקרשתןךםףץ"; const string Portuguese = "áéíóúÉâêôãõÃÕçÇ";
readonly byte[] HebrewBytes = { 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, readonly byte[] PortugueseBytes =
0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC}; {0xA0, 0x82, 0xA1, 0xA2, 0xA3, 0x90, 0x83, 0x88, 0x93, 0xB0, 0xB1, 0xB7, 0xB8, 0x87, 0x80};
const string Greek = "αβΓπΣσµτΦΘΩδ¯"; const string Dutch = "ijIJ";
readonly byte[] GreekBytes = { 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xFF }; readonly byte[] DutchBytes = {0xC0, 0xC1};
const string Hebrew = "אבגדהוזחטיכלמנסעפצקרשתןךםףץ";
readonly byte[] HebrewBytes =
{
0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3,
0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC
};
const string Greek = "αβΓπΣσµτΦΘΩδ¯";
readonly byte[] GreekBytes = {0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xFF};
const string Typographic = "ªº«»¨´†¶©®™§°∙·"; const string Typographic = "ªº«»¨´†¶©®™§°∙·";
readonly byte[] TypographicBytes = { 0xA6, 0xA7, 0xAE, 0xAF, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xDD, 0xF8, 0xF9, 0xFA }; readonly byte[] TypographicBytes =
const string Currency = "¢£¥ƒ"; {0xA6, 0xA7, 0xAE, 0xAF, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xDD, 0xF8, 0xF9, 0xFA};
readonly byte[] CurrencyBytes = { 0x9B, 0x9C, 0x9D, 0x9F }; const string Currency = "¢£¥ƒ";
const string Mathematics = "⌐¬½¼∧∞∮ϕ∈∩≡±≥≤⌠⌡÷≈√ⁿ²³"; readonly byte[] CurrencyBytes = {0x9B, 0x9C, 0x9D, 0x9F};
readonly byte[] MathematicsBytes = { 0xA9, 0xAA, 0xAB, 0xAC, 0xDE, 0xDF, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xFB, 0xFC, const string Mathematics = "⌐¬½¼∧∞∮ϕ∈∩≡±≥≤⌠⌡÷≈√ⁿ²³";
0xFD, 0xFE}; readonly byte[] MathematicsBytes =
const string Symbols = "⇧⇩⇨⇦❎✓♪ə"; {
readonly byte[] SymbolsBytes = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x0B, 0x1A }; 0xA9, 0xAA, 0xAB, 0xAC, 0xDE, 0xDF, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
0xFB, 0xFC, 0xFD, 0xFE
};
const string Symbols = "⇧⇩⇨⇦❎✓♪ə";
readonly byte[] SymbolsBytes = {0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x0B, 0x1A};
[Test]
public void AtariSTPangrams()
{
byte[] byteArray;
string testString;
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Basque);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Basque, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Danish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Danish, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.English);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.English, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Finnish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Finnish, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.French);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.French, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Galician);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Galician, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.German);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.German, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Hebrew);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Hebrew, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Norwegian);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Norwegian, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Portuguese);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Portuguese, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Spanish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Spanish, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Swedish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Swedish, testString);
}
[Test]
public void AtariSTToUnicode()
{
string testString;
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(SpanishBytes);
Assert.AreEqual(Spanish, testString);
testString = Encoding.AtariSTEncoding.GetString(FrenchBytes);
Assert.AreEqual(French, testString);
testString = Encoding.AtariSTEncoding.GetString(GermanBytes);
Assert.AreEqual(German, testString);
testString = Encoding.AtariSTEncoding.GetString(NorwegianBytes);
Assert.AreEqual(Norwegian, testString);
testString = Encoding.AtariSTEncoding.GetString(PortugueseBytes);
Assert.AreEqual(Portuguese, testString);
testString = Encoding.AtariSTEncoding.GetString(DutchBytes);
Assert.AreEqual(Dutch, testString);
testString = Encoding.AtariSTEncoding.GetString(HebrewBytes);
Assert.AreEqual(Hebrew, testString);
testString = Encoding.AtariSTEncoding.GetString(GreekBytes);
Assert.AreEqual(Greek, testString);
testString = Encoding.AtariSTEncoding.GetString(TypographicBytes);
Assert.AreEqual(Typographic, testString);
testString = Encoding.AtariSTEncoding.GetString(CurrencyBytes);
Assert.AreEqual(Currency, testString);
testString = Encoding.AtariSTEncoding.GetString(MathematicsBytes);
Assert.AreEqual(Mathematics, testString);
testString = Encoding.AtariSTEncoding.GetString(SymbolsBytes);
Assert.AreEqual(Symbols, testString);
// TODO: 0x09 => U+1F552, 0x0A => U+1F514
/*testString = Encoding.AtariSTEncoding.GetString(SymbolsUnicode32Bytes);
Assert.AreEqual(SymbolsUnicode32, testString);*/
}
// TODO: 0x09 => U+1F552, 0x0A => U+1F514 // TODO: 0x09 => U+1F552, 0x0A => U+1F514
/*const string SymbolsUnicode32 = "\ud83d\udd52\ud83d\udd14"; /*const string SymbolsUnicode32 = "\ud83d\udd52\ud83d\udd14";
readonly byte[] SymbolsUnicode32Bytes = { 0x09, 0x0A };*/ readonly byte[] SymbolsUnicode32Bytes = { 0x09, 0x0A };*/
@@ -118,93 +226,5 @@ namespace Claunia.Encoding.Tests
/*byteArray = Encoding.AtariSTEncoding.GetBytes(SymbolsUnicode32); /*byteArray = Encoding.AtariSTEncoding.GetBytes(SymbolsUnicode32);
Assert.AreEqual(SymbolsUnicode32Bytes, byteArray);*/ Assert.AreEqual(SymbolsUnicode32Bytes, byteArray);*/
} }
[Test]
public void AtariSTToUnicode()
{
string testString;
testString = Encoding.AtariSTEncoding.GetString(PunctuationsBytes);
Assert.AreEqual(Punctuations, testString);
testString = Encoding.AtariSTEncoding.GetString(DigitsBytes);
Assert.AreEqual(Digits, testString);
testString = Encoding.AtariSTEncoding.GetString(UpperLatinBytes);
Assert.AreEqual(UpperLatin, testString);
testString = Encoding.AtariSTEncoding.GetString(LowerLatinBytes);
Assert.AreEqual(LowerLatin, testString);
testString = Encoding.AtariSTEncoding.GetString(SpanishBytes);
Assert.AreEqual(Spanish, testString);
testString = Encoding.AtariSTEncoding.GetString(FrenchBytes);
Assert.AreEqual(French, testString);
testString = Encoding.AtariSTEncoding.GetString(GermanBytes);
Assert.AreEqual(German, testString);
testString = Encoding.AtariSTEncoding.GetString(NorwegianBytes);
Assert.AreEqual(Norwegian, testString);
testString = Encoding.AtariSTEncoding.GetString(PortugueseBytes);
Assert.AreEqual(Portuguese, testString);
testString = Encoding.AtariSTEncoding.GetString(DutchBytes);
Assert.AreEqual(Dutch, testString);
testString = Encoding.AtariSTEncoding.GetString(HebrewBytes);
Assert.AreEqual(Hebrew, testString);
testString = Encoding.AtariSTEncoding.GetString(GreekBytes);
Assert.AreEqual(Greek, testString);
testString = Encoding.AtariSTEncoding.GetString(TypographicBytes);
Assert.AreEqual(Typographic, testString);
testString = Encoding.AtariSTEncoding.GetString(CurrencyBytes);
Assert.AreEqual(Currency, testString);
testString = Encoding.AtariSTEncoding.GetString(MathematicsBytes);
Assert.AreEqual(Mathematics, testString);
testString = Encoding.AtariSTEncoding.GetString(SymbolsBytes);
Assert.AreEqual(Symbols, testString);
// TODO: 0x09 => U+1F552, 0x0A => U+1F514
/*testString = Encoding.AtariSTEncoding.GetString(SymbolsUnicode32Bytes);
Assert.AreEqual(SymbolsUnicode32, testString);*/
}
[Test]
public void AtariSTPangrams()
{
byte[] byteArray;
string testString;
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Basque);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Basque, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Danish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Danish, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.English);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.English, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Finnish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Finnish, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.French);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.French, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Galician);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Galician, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.German);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.German, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Hebrew);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Hebrew, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Norwegian);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Norwegian, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Portuguese);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Portuguese, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Spanish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Spanish, testString);
byteArray = Encoding.AtariSTEncoding.GetBytes(Pangrams.Swedish);
testString = Encoding.AtariSTEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Swedish, testString);
}
} }
} }

View File

@@ -23,48 +23,49 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
using System; using System;
using NUnit.Framework; using NUnit.Framework;
namespace Claunia.Encoding.Tests namespace Claunia.Encoding.Tests
{ {
[TestFixture] [TestFixture]
public class GetEncs public class GetEncs
{ {
[Test] [Test]
// Well basically this is taken from MSDN's documentation :p // Well basically this is taken from MSDN's documentation :p
public void GetAllEncs() public void GetAllEncs()
{ {
// Print the header. // Print the header.
Console.Write("CodePage identifier and name "); Console.Write("CodePage identifier and name ");
Console.Write("BrDisp BrSave "); Console.Write("BrDisp BrSave ");
Console.Write("MNDisp MNSave "); Console.Write("MNDisp MNSave ");
Console.WriteLine("1-Byte ReadOnly "); Console.WriteLine("1-Byte ReadOnly ");
// For every encoding, get the property values. // For every encoding, get the property values.
foreach(EncodingInfo ei in Encoding.GetEncodings()) foreach(EncodingInfo ei in Encoding.GetEncodings())
{ {
Encoding e = ei.GetEncoding(); Encoding e = ei.GetEncoding();
Console.Write("{0,-6} {1,-25} ", ei.CodePage, ei.Name); 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.IsBrowserDisplay, e.IsBrowserSave);
Console.Write("{0,-8} {1,-8} ", e.IsMailNewsDisplay, e.IsMailNewsSave); Console.Write("{0,-8} {1,-8} ", e.IsMailNewsDisplay, e.IsMailNewsSave);
Console.WriteLine("{0,-8} {1,-8} ", e.IsSingleByte, e.IsReadOnly); Console.WriteLine("{0,-8} {1,-8} ", e.IsSingleByte, e.IsReadOnly);
} }
} }
[Test]
// Well basically this is taken from MSDN's documentation :p
public void GetInternalEncoding()
{
System.Text.Encoding e = Encoding.GetEncoding("lisa");
}
[Test] [Test]
// Well basically this is taken from MSDN's documentation :p // Well basically this is taken from MSDN's documentation :p
public void GetExternalEncoding() public void GetExternalEncoding()
{ {
System.Text.Encoding e = Encoding.GetEncoding("shift_jis"); System.Text.Encoding e = Encoding.GetEncoding("shift_jis");
} }
}
[Test]
// Well basically this is taken from MSDN's documentation :p
public void GetInternalEncoding()
{
System.Text.Encoding e = Encoding.GetEncoding("lisa");
}
}
} }

View File

@@ -32,66 +32,102 @@ namespace Claunia.Encoding.Tests
public class LisaRoman public class LisaRoman
{ {
const string Punctuations = "!\"#$%&()*+,-./:;<=>?@[\\]^_{|}~"; 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, readonly byte[] PunctuationsBytes =
0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7B, 0x7C, 0x7D, 0x7E }; {
const string Digits = "0123456789"; 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D,
readonly byte[] DigitsBytes = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 }; 0x3E, 0x3F, 0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x7B, 0x7C, 0x7D, 0x7E
const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; };
readonly byte[] UpperLatinBytes = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, const string Digits = "0123456789";
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A }; readonly byte[] DigitsBytes = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};
const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
readonly byte[] UpperLatinBytes =
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A
};
const string LowerLatin = "abcdefghijklmnopqrstuvwxyz"; const string LowerLatin = "abcdefghijklmnopqrstuvwxyz";
readonly byte[] LowerLatinBytes = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, readonly byte[] LowerLatinBytes =
0x75, 0x76, 0x77, 0x78, 0x79, 0x7A }; {
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 = "¡¿áéíóúüñÉÜÑ"; const string Spanish = "¡¿áéíóúüñÉÜÑ";
readonly byte[] SpanishBytes = { 0xC1, 0xC0, 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x9F, 0x96, 0x83, 0x86, 0x84 }; readonly byte[] SpanishBytes = {0xC1, 0xC0, 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x9F, 0x96, 0x83, 0x86, 0x84};
const string French = "éÉàèùÀâêîôûëïüÿçÇœŒæÆ"; 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 }; readonly byte[] FrenchBytes =
const string German = "äöüßÄÖÜ"; {
readonly byte[] GermanBytes = { 0x8A, 0x9A, 0x9F, 0xA7, 0x80, 0x85, 0x86 }; 0x8E, 0x83, 0x88, 0x8F, 0x9D, 0xCB, 0x89, 0x90, 0x94, 0x99, 0x9E, 0x91, 0x95, 0x9F, 0xD8, 0x8D, 0x82, 0xCF,
const string Norwegian = "æøåÆØÅ"; 0xCE, 0xBE, 0xAE
readonly byte[] NorwegianBytes = { 0xBE, 0xBF, 0x8C, 0xAE, 0xAF, 0x81 }; };
const string Portuguese = "áéíóúÉâêôãõÃÕçÇ"; const string German = "äöüßÄÖÜ";
readonly byte[] PortugueseBytes = { 0x87, 0x8E, 0x92, 0x97, 0x9C, 0x83, 0x89, 0x90, 0x99, 0x8B, 0x9B, 0xCC, 0xCD, 0x8D, 0x82 }; 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 = "†°•¶®©™´¨ªº«»…–—“”‘’§"; 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}; readonly byte[] TypographicBytes =
const string Currency = "¢£¥"; {
readonly byte[] CurrencyBytes = { 0xA2, 0xA3, 0xB4 }; 0xA0, 0xA1, 0xA5, 0xA6, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xBB, 0xBC, 0xC7, 0xC8, 0xC9, 0xD0, 0xD1, 0xD2, 0xD3,
const string Mathematics = "≠∞±≤≥µ∂∑∏π∫Ω¬√ƒ≈∆÷◊"; 0xD4, 0xD5, 0xA4
readonly byte[] MathematicsBytes = { 0xAD, 0xB0, 0xB1, 0xB2, 0xB3, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBD, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xD6, 0xD7 }; };
const string Currency = "¢£¥";
readonly byte[] CurrencyBytes = {0xA2, 0xA3, 0xB4};
const string Mathematics = "≠∞±≤≥µ∂∑∏π∫Ω¬√ƒ≈∆÷◊";
readonly byte[] MathematicsBytes =
{
0xAD, 0xB0, 0xB1, 0xB2, 0xB3, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBD, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xD6,
0xD7
};
[Test] [Test]
public void UnicodeToLisa() public void LisaPangrams()
{ {
byte[] byteArray; byte[] byteArray;
string testString;
byteArray = Encoding.LisaEncoding.GetBytes(Punctuations); byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Basque);
Assert.AreEqual(PunctuationsBytes, byteArray); testString = Encoding.LisaEncoding.GetString(byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Digits); Assert.AreEqual(Pangrams.Basque, testString);
Assert.AreEqual(DigitsBytes, byteArray); byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Breton);
byteArray = Encoding.LisaEncoding.GetBytes(UpperLatin); testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(UpperLatinBytes, byteArray); Assert.AreEqual(Pangrams.Breton, testString);
byteArray = Encoding.LisaEncoding.GetBytes(LowerLatin); byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Danish);
Assert.AreEqual(LowerLatinBytes, byteArray); testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Danish, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Spanish); byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Dutch);
Assert.AreEqual(SpanishBytes, byteArray); testString = Encoding.LisaEncoding.GetString(byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(French); Assert.AreEqual(Pangrams.Dutch, testString);
Assert.AreEqual(FrenchBytes, byteArray); byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.English);
byteArray = Encoding.LisaEncoding.GetBytes(German); testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(GermanBytes, byteArray); Assert.AreEqual(Pangrams.English, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Norwegian); byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Finnish);
Assert.AreEqual(NorwegianBytes, byteArray); testString = Encoding.LisaEncoding.GetString(byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Portuguese); Assert.AreEqual(Pangrams.Finnish, testString);
Assert.AreEqual(PortugueseBytes, byteArray); byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.French);
testString = Encoding.LisaEncoding.GetString(byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Typographic); Assert.AreEqual(Pangrams.French, testString);
Assert.AreEqual(TypographicBytes, byteArray); byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Galician);
byteArray = Encoding.LisaEncoding.GetBytes(Currency); testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(CurrencyBytes, byteArray); Assert.AreEqual(Pangrams.Galician, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Mathematics); byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.German);
Assert.AreEqual(MathematicsBytes, byteArray); testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.German, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Norwegian);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Norwegian, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Portuguese);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Portuguese, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Spanish);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Spanish, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Swedish);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Swedish, testString);
} }
[Test] [Test]
@@ -128,50 +164,36 @@ namespace Claunia.Encoding.Tests
} }
[Test] [Test]
public void LisaPangrams() public void UnicodeToLisa()
{ {
byte[] byteArray; byte[] byteArray;
string testString;
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Basque); byteArray = Encoding.LisaEncoding.GetBytes(Punctuations);
testString = Encoding.LisaEncoding.GetString(byteArray); Assert.AreEqual(PunctuationsBytes, byteArray);
Assert.AreEqual(Pangrams.Basque, testString); byteArray = Encoding.LisaEncoding.GetBytes(Digits);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Breton); Assert.AreEqual(DigitsBytes, byteArray);
testString = Encoding.LisaEncoding.GetString(byteArray); byteArray = Encoding.LisaEncoding.GetBytes(UpperLatin);
Assert.AreEqual(Pangrams.Breton, testString); Assert.AreEqual(UpperLatinBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Danish); byteArray = Encoding.LisaEncoding.GetBytes(LowerLatin);
testString = Encoding.LisaEncoding.GetString(byteArray); Assert.AreEqual(LowerLatinBytes, byteArray);
Assert.AreEqual(Pangrams.Danish, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Dutch); byteArray = Encoding.LisaEncoding.GetBytes(Spanish);
testString = Encoding.LisaEncoding.GetString(byteArray); Assert.AreEqual(SpanishBytes, byteArray);
Assert.AreEqual(Pangrams.Dutch, testString); byteArray = Encoding.LisaEncoding.GetBytes(French);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.English); Assert.AreEqual(FrenchBytes, byteArray);
testString = Encoding.LisaEncoding.GetString(byteArray); byteArray = Encoding.LisaEncoding.GetBytes(German);
Assert.AreEqual(Pangrams.English, testString); Assert.AreEqual(GermanBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Finnish); byteArray = Encoding.LisaEncoding.GetBytes(Norwegian);
testString = Encoding.LisaEncoding.GetString(byteArray); Assert.AreEqual(NorwegianBytes, byteArray);
Assert.AreEqual(Pangrams.Finnish, testString); byteArray = Encoding.LisaEncoding.GetBytes(Portuguese);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.French); Assert.AreEqual(PortugueseBytes, byteArray);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.French, testString); byteArray = Encoding.LisaEncoding.GetBytes(Typographic);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Galician); Assert.AreEqual(TypographicBytes, byteArray);
testString = Encoding.LisaEncoding.GetString(byteArray); byteArray = Encoding.LisaEncoding.GetBytes(Currency);
Assert.AreEqual(Pangrams.Galician, testString); Assert.AreEqual(CurrencyBytes, byteArray);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.German); byteArray = Encoding.LisaEncoding.GetBytes(Mathematics);
testString = Encoding.LisaEncoding.GetString(byteArray); Assert.AreEqual(MathematicsBytes, byteArray);
Assert.AreEqual(Pangrams.German, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Norwegian);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Norwegian, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Portuguese);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Portuguese, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Spanish);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Spanish, testString);
byteArray = Encoding.LisaEncoding.GetBytes(Pangrams.Swedish);
testString = Encoding.LisaEncoding.GetString(byteArray);
Assert.AreEqual(Pangrams.Swedish, testString);
} }
} }
} }

View File

@@ -31,9 +31,9 @@ namespace Claunia.Encoding.Tests
[TestFixture] [TestFixture]
public class Radix50 public class Radix50
{ {
const string Punctuations = " .$%"; const string Punctuations = " .$%";
readonly byte[] PunctuationsBytes = {0b00000001, 0b11000110, 0b11011101}; readonly byte[] PunctuationsBytes = {0b00000001, 0b11000110, 0b11011101};
const string Digits = "0123456789"; const string Digits = "0123456789";
readonly byte[] DigitsBytes = readonly byte[] DigitsBytes =
{0b01111001, 0b11111000, 0b00100001, 0b10001010, 0b00111001, 0b00100101, 0b10011010, 0b01110000}; {0b01111001, 0b11111000, 0b00100001, 0b10001010, 0b00111001, 0b00100101, 0b10011010, 0b01110000};
const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const string UpperLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -43,7 +43,7 @@ namespace Claunia.Encoding.Tests
0b00110100, 0b11100011, 0b11010000, 0b01000101, 0b00100100, 0b11010100, 0b01010101, 0b01100101, 0b11011000, 0b00110100, 0b11100011, 0b11010000, 0b01000101, 0b00100100, 0b11010100, 0b01010101, 0b01100101, 0b11011000,
0b01100101, 0b10100000 0b01100101, 0b10100000
}; };
const string Sentence = "THIS IS A TEST$"; const string Sentence = "THIS IS A TEST$";
const string SentencePadded = "THIS IS A TEST$ "; // It gets space padded when decoding is not multiple const string SentencePadded = "THIS IS A TEST$ "; // It gets space padded when decoding is not multiple
readonly byte[] SentenceBytes = readonly byte[] SentenceBytes =
{ {

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class ATASCII : Encoding public class ATASCII : Encoding
{ {
const string _bodyname = "atascii"; const string _bodyname = "atascii";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Atari Standard Code for Information Interchange"; const string _encodingname = "Atari Standard Code for Information Interchange";
const string _headername = "atascii"; const string _headername = "atascii";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = false; const bool readOnly = false;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The ATASCII to Unicode character map. /// The ATASCII to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class Apple2 : Encoding public class Apple2 : Encoding
{ {
const string _bodyname = "apple2"; const string _bodyname = "apple2";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Western European (Apple II)"; const string _encodingname = "Western European (Apple II)";
const string _headername = "apple2"; const string _headername = "apple2";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = false; const bool readOnly = false;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Apple II to Unicode character map. /// The Apple II to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class Apple2c : Encoding public class Apple2c : Encoding
{ {
const string _bodyname = "apple2c"; const string _bodyname = "apple2c";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Western European (Apple IIc)"; const string _encodingname = "Western European (Apple IIc)";
const string _headername = "apple2c"; const string _headername = "apple2c";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Apple IIc to Unicode character map. /// The Apple IIc to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class Apple2e : Encoding public class Apple2e : Encoding
{ {
const string _bodyname = "apple2e"; const string _bodyname = "apple2e";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Western European (Apple IIe)"; const string _encodingname = "Western European (Apple IIe)";
const string _headername = "apple2e"; const string _headername = "apple2e";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Apple IIe to Unicode character map. /// The Apple IIe to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class Apple2gs : Encoding public class Apple2gs : Encoding
{ {
const string _bodyname = "apple2gs"; const string _bodyname = "apple2gs";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Western European (Apple IIgs)"; const string _encodingname = "Western European (Apple IIgs)";
const string _headername = "apple2gs"; const string _headername = "apple2gs";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Apple IIgs to Unicode character map. /// The Apple IIgs to Unicode character map.

View File

@@ -34,19 +34,19 @@ namespace Claunia.Encoding
// TODO: 0x09 => U+1F552, 0x0A => U+1F514 // TODO: 0x09 => U+1F552, 0x0A => U+1F514
public class AtariST : Encoding public class AtariST : Encoding
{ {
const string _bodyname = "atarist"; const string _bodyname = "atarist";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Western European (Atari ST)"; const string _encodingname = "Western European (Atari ST)";
const string _headername = "atarist"; const string _headername = "atarist";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = false; const bool readOnly = false;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Atari ST to Unicode character map. /// The Atari ST to Unicode character map.

View File

@@ -132,7 +132,7 @@ namespace Claunia.Encoding
where type.IsSubclassOf(typeof(Encoding)) where type.IsSubclassOf(typeof(Encoding))
let encoding = (Encoding)type.GetConstructor(new Type[] { }).Invoke(new object[] { }) let encoding = (Encoding)type.GetConstructor(new Type[] { }).Invoke(new object[] { })
select new EncodingInfo(encoding.CodePage, encoding.BodyName, encoding.EncodingName, false, type)) select new EncodingInfo(encoding.CodePage, encoding.BodyName, encoding.EncodingName, false, type))
.ToArray(); .ToArray();
} }
/// <summary> /// <summary>

View File

@@ -14,14 +14,14 @@ namespace Claunia.Encoding
bool isSystem; bool isSystem;
Type thisType; Type thisType;
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) Type internalType = null)
{ {
CodePage = codePage; CodePage = codePage;
Name = name; Name = name;
DisplayName = displayName; DisplayName = displayName;
isSystem = system; isSystem = system;
thisType = internalType; thisType = internalType;
} }
/// <summary> /// <summary>

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class Gem : Encoding public class Gem : Encoding
{ {
const string _bodyname = "gem"; const string _bodyname = "gem";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Western European (GEM)"; const string _encodingname = "Western European (GEM)";
const string _headername = "gem"; const string _headername = "gem";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = false; const bool readOnly = false;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The GEM to Unicode character map. /// The GEM to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class LisaRoman : Encoding public class LisaRoman : Encoding
{ {
const string _bodyname = "lisa"; const string _bodyname = "lisa";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Western European (Apple Lisa)"; const string _encodingname = "Western European (Apple Lisa)";
const string _headername = "lisa"; const string _headername = "lisa";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 10000; const int _windowsCodepage = 10000;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = false; const bool readOnly = false;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Lisa to Unicode character map. /// The Lisa to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacArabic : Encoding public class MacArabic : Encoding
{ {
const string _bodyname = "x-mac-arabic"; const string _bodyname = "x-mac-arabic";
const int _codepage = 10004; const int _codepage = 10004;
const string _encodingname = "Arabic (Mac)"; const string _encodingname = "Arabic (Mac)";
const string _headername = "x-mac-arabic"; const string _headername = "x-mac-arabic";
const string _webname = "x-mac-arabic"; const string _webname = "x-mac-arabic";
const int _windowsCodepage = 10004; const int _windowsCodepage = 10004;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Macintosh Arabic to Unicode character map. /// The Macintosh Arabic to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacCentralEuropean : Encoding public class MacCentralEuropean : Encoding
{ {
const string _bodyname = "x-mac-ce"; const string _bodyname = "x-mac-ce";
const int _codepage = 10029; const int _codepage = 10029;
const string _encodingname = "Central European (Mac)"; const string _encodingname = "Central European (Mac)";
const string _headername = "x-mac-ce"; const string _headername = "x-mac-ce";
const string _webname = "x-mac-ce"; const string _webname = "x-mac-ce";
const int _windowsCodepage = 10029; const int _windowsCodepage = 10029;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Macintosh CentralEuropean to Unicode character map. /// The Macintosh CentralEuropean to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacCroatian : Encoding public class MacCroatian : Encoding
{ {
const string _bodyname = "x-mac-croatian"; const string _bodyname = "x-mac-croatian";
const int _codepage = 10082; const int _codepage = 10082;
const string _encodingname = "Croatian (Mac)"; const string _encodingname = "Croatian (Mac)";
const string _headername = "x-mac-croatian"; const string _headername = "x-mac-croatian";
const string _webname = "x-mac-croatian"; const string _webname = "x-mac-croatian";
const int _windowsCodepage = 10082; const int _windowsCodepage = 10082;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Macintosh Croatian to Unicode character map. /// The Macintosh Croatian to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacCyrillic : Encoding public class MacCyrillic : Encoding
{ {
const string _bodyname = "x-mac-cyrillic"; const string _bodyname = "x-mac-cyrillic";
const int _codepage = 10007; const int _codepage = 10007;
const string _encodingname = "Cyrillic (Mac)"; const string _encodingname = "Cyrillic (Mac)";
const string _headername = "x-mac-cyrillic"; const string _headername = "x-mac-cyrillic";
const string _webname = "x-mac-cyrillic"; const string _webname = "x-mac-cyrillic";
const int _windowsCodepage = 10007; const int _windowsCodepage = 10007;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Macintosh Cyrillic to Unicode character map. /// The Macintosh Cyrillic to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacFarsi : Encoding public class MacFarsi : Encoding
{ {
const string _bodyname = "x-mac-farsi"; const string _bodyname = "x-mac-farsi";
const int _codepage = 10014; const int _codepage = 10014;
const string _encodingname = "Farsi (Mac)"; const string _encodingname = "Farsi (Mac)";
const string _headername = "x-mac-farsi"; const string _headername = "x-mac-farsi";
const string _webname = "x-mac-farsi"; const string _webname = "x-mac-farsi";
const int _windowsCodepage = 10014; const int _windowsCodepage = 10014;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Macintosh Farsi to Unicode character map. /// The Macintosh Farsi to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacGreek : Encoding public class MacGreek : Encoding
{ {
const string _bodyname = "x-mac-greek"; const string _bodyname = "x-mac-greek";
const int _codepage = 10006; const int _codepage = 10006;
const string _encodingname = "Greek (Mac)"; const string _encodingname = "Greek (Mac)";
const string _headername = "x-mac-greek"; const string _headername = "x-mac-greek";
const string _webname = "x-mac-greek"; const string _webname = "x-mac-greek";
const int _windowsCodepage = 10006; const int _windowsCodepage = 10006;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Macintosh Greek to Unicode character map. /// The Macintosh Greek to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacHebrew : Encoding public class MacHebrew : Encoding
{ {
const string _bodyname = "x-mac-hebrew"; const string _bodyname = "x-mac-hebrew";
const int _codepage = 10005; const int _codepage = 10005;
const string _encodingname = "Hebrew (Mac)"; const string _encodingname = "Hebrew (Mac)";
const string _headername = "x-mac-hebrew"; const string _headername = "x-mac-hebrew";
const string _webname = "x-mac-hebrew"; const string _webname = "x-mac-hebrew";
const int _windowsCodepage = 10005; const int _windowsCodepage = 10005;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Macintosh Hebrew to Unicode character map. /// The Macintosh Hebrew to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacRoman : Encoding public class MacRoman : Encoding
{ {
const string _bodyname = "macintosh"; const string _bodyname = "macintosh";
const int _codepage = 10000; const int _codepage = 10000;
const string _encodingname = "Western European (Mac)"; const string _encodingname = "Western European (Mac)";
const string _headername = "macintosh"; const string _headername = "macintosh";
const string _webname = "macintosh"; const string _webname = "macintosh";
const int _windowsCodepage = 10000; const int _windowsCodepage = 10000;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Mac to Unicode character map. /// The Mac to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacRomanian : Encoding public class MacRomanian : Encoding
{ {
const string _bodyname = "x-mac-romanian"; const string _bodyname = "x-mac-romanian";
const int _codepage = 10010; const int _codepage = 10010;
const string _encodingname = "Romanianian (Mac)"; const string _encodingname = "Romanianian (Mac)";
const string _headername = "x-mac-romanian"; const string _headername = "x-mac-romanian";
const string _webname = "x-mac-romanian"; const string _webname = "x-mac-romanian";
const int _windowsCodepage = 10010; const int _windowsCodepage = 10010;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Mac to Unicode character map. /// The Mac to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacTurkish : Encoding public class MacTurkish : Encoding
{ {
const string _bodyname = "x-mac-turkish"; const string _bodyname = "x-mac-turkish";
const int _codepage = 10081; const int _codepage = 10081;
const string _encodingname = "Turkish (Mac)"; const string _encodingname = "Turkish (Mac)";
const string _headername = "x-mac-turkish"; const string _headername = "x-mac-turkish";
const string _webname = "x-mac-turkish"; const string _webname = "x-mac-turkish";
const int _windowsCodepage = 10081; const int _windowsCodepage = 10081;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Macintosh Turkish to Unicode character map. /// The Macintosh Turkish to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class MacUkrainian : Encoding public class MacUkrainian : Encoding
{ {
const string _bodyname = "x-mac-ukrainian"; const string _bodyname = "x-mac-ukrainian";
const int _codepage = 10017; const int _codepage = 10017;
const string _encodingname = "Ukrainian (Mac)"; const string _encodingname = "Ukrainian (Mac)";
const string _headername = "x-mac-ukrainian"; const string _headername = "x-mac-ukrainian";
const string _webname = "x-mac-ukrainian"; const string _webname = "x-mac-ukrainian";
const int _windowsCodepage = 10017; const int _windowsCodepage = 10017;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = true; const bool readOnly = true;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The Macintosh Ukrainian to Unicode character map. /// The Macintosh Ukrainian to Unicode character map.

View File

@@ -34,19 +34,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class PETSCII : Encoding public class PETSCII : Encoding
{ {
const string _bodyname = "petscii"; const string _bodyname = "petscii";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Commodore PET Standard Code for Information Interchange"; const string _encodingname = "Commodore PET Standard Code for Information Interchange";
const string _headername = "petscii"; const string _headername = "petscii";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = false; const bool readOnly = false;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The PETSCII to Unicode character map, unshifted (default) variant. /// The PETSCII to Unicode character map, unshifted (default) variant.
@@ -494,7 +494,8 @@ namespace Claunia.Encoding
for(int i = 0; i < 256; i++) for(int i = 0; i < 256; i++)
// TODO: convert this to a gigantic switch statement too? // TODO: convert this to a gigantic switch statement too?
if(PETSCIITable[i] == character) return (byte)i; if(PETSCIITable[i] == character)
return (byte)i;
// Fallback to '?' // Fallback to '?'
return 0x3F; return 0x3F;

View File

@@ -68,12 +68,10 @@ namespace Claunia.Encoding
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.";
/// <summary>A pangram that contains all (or most) Finnish characters.</summary> /// <summary>A pangram that contains all (or most) Finnish characters.</summary>
public const string Finnish = public const string Finnish =
"Fahrenheit ja Celsius yrjösivät Åsan backgammon-peliin, Volkswagenissa, daiquirin ja ZX81:n yhteisvaikutuksesta." "Fahrenheit ja Celsius yrjösivät Åsan backgammon-peliin, Volkswagenissa, daiquirin ja ZX81:n yhteisvaikutuksesta.";
;
/// <summary>A pangram that contains all (or most) French characters.</summary> /// <summary>A pangram that contains all (or most) French characters.</summary>
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æ." "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æ.";
;
/// <summary>A pangram that contains all (or most) Galician characters.</summary> /// <summary>A pangram that contains all (or most) Galician characters.</summary>
public const string Galician = public const string Galician =
"Necesitamos unha tipografía chuliña de cor kiwi, que lle zorregue unha labazada visual á xente."; "Necesitamos unha tipografía chuliña de cor kiwi, que lle zorregue unha labazada visual á xente.";
@@ -81,12 +79,10 @@ namespace Claunia.Encoding
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.";
/// <summary>A pangram that contains all (or most) Greek characters.</summary> /// <summary>A pangram that contains all (or most) Greek characters.</summary>
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." "Ταχίστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός Takhístè alôpèx vaphês psèménè gè, draskelízei ypér nòthroý kynós.";
;
/// <summary>A pangram that contains all (or most) Hebrew characters.</summary> /// <summary>A pangram that contains all (or most) Hebrew characters.</summary>
public const string Hebrew = public const string Hebrew =
"לכן חכו לי נאם יהוה ליום קומי לעד, כי משפטי לאסף גוים לקבצי ממלכות, לשפך עליהם זעמי כל חרון אפי, כי באש קנאתי תאכל כל הארץ" "לכן חכו לי נאם יהוה ליום קומי לעד, כי משפטי לאסף גוים לקבצי ממלכות, לשפך עליהם זעמי כל חרון אפי, כי באש קנאתי תאכל כל הארץ";
;
/// <summary>A pangram that contains all (or most) Hungarian characters.</summary> /// <summary>A pangram that contains all (or most) Hungarian characters.</summary>
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.";
/// <summary>A pangram that contains all (or most) Icelandic characters.</summary> /// <summary>A pangram that contains all (or most) Icelandic characters.</summary>
@@ -111,8 +107,7 @@ namespace Claunia.Encoding
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!";
/// <summary>A pangram that contains all (or most) Portuguese characters.</summary> /// <summary>A pangram that contains all (or most) Portuguese characters.</summary>
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." "À 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.";
;
/// <summary>A pangram that contains all (or most) Romanian characters.</summary> /// <summary>A pangram that contains all (or most) Romanian characters.</summary>
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.";
/// <summary>A pangram that contains all (or most) Russian characters.</summary> /// <summary>A pangram that contains all (or most) Russian characters.</summary>
@@ -129,8 +124,7 @@ namespace Claunia.Encoding
public const string Slovenian = "Besni dirkač iz formule žuga cehu poštarjev."; public const string Slovenian = "Besni dirkač iz formule žuga cehu poštarjev.";
/// <summary>A pangram that contains all (or most) Spanish characters.</summary> /// <summary>A pangram that contains all (or most) Spanish characters.</summary>
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." "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.";
;
/// <summary>A pangram that contains all (or most) Swedish characters.</summary> /// <summary>A pangram that contains all (or most) Swedish characters.</summary>
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.";
/// <summary>A pangram that contains all (or most) Turkish characters.</summary> /// <summary>A pangram that contains all (or most) Turkish characters.</summary>

View File

@@ -25,30 +25,29 @@
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes. // Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project. // Change them to the values specific to your project.
[assembly: AssemblyTitle ("Claunia.Encoding")] [assembly: AssemblyTitle("Claunia.Encoding")]
[assembly: AssemblyDescription ("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration ("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany ("Claunia.com")] [assembly: AssemblyCompany("Claunia.com")]
[assembly: AssemblyProduct ("")] [assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright ("© Natalia Portillo")] [assembly: AssemblyCopyright("© Natalia Portillo")]
[assembly: AssemblyTrademark ("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture ("")] [assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision, // The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision. // and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.4.*")] [assembly: AssemblyVersion("1.4.*")]
// The following attributes are used to specify the signing key for the assembly, // The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing. // if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)] //[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")] //[assembly: AssemblyKeyFile("")]

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class Radix50 : Encoding public class Radix50 : Encoding
{ {
const string _bodyname = "radix50"; const string _bodyname = "radix50";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Western European (Radix-50)"; const string _encodingname = "Western European (Radix-50)";
const string _headername = "radix50"; const string _headername = "radix50";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = false; const bool readOnly = false;
const bool singleByte = false; const bool singleByte = false;
/// <summary> /// <summary>
/// The Radix-50 to Unicode character map, when bits are shifted right /// The Radix-50 to Unicode character map, when bits are shifted right
@@ -252,8 +252,8 @@ namespace Claunia.Encoding
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; int outPos = 0;
for(int i = 0; i < count; i++) for(int i = 0; i < count; i++)
{ {
@@ -269,20 +269,20 @@ namespace Claunia.Encoding
case 1: case 1:
if(outPos + 1 >= bytes.Length) break; if(outPos + 1 >= bytes.Length) break;
bytes[outPos] += (byte)((thisByte & 0x30) >> 4); bytes[outPos] += (byte)((thisByte & 0x30) >> 4);
bytes[outPos + 1] = (byte)((thisByte & 0xF) << 4); bytes[outPos + 1] = (byte)((thisByte & 0xF) << 4);
break; break;
case 2: case 2:
if(outPos + 2 >= bytes.Length) break; if(outPos + 2 >= bytes.Length) break;
bytes[outPos + 1] += (byte)((thisByte & 0x3C) >> 2); bytes[outPos + 1] += (byte)((thisByte & 0x3C) >> 2);
bytes[outPos + 2] = (byte)((thisByte & 0x3) << 6); bytes[outPos + 2] = (byte)((thisByte & 0x3) << 6);
break; break;
case 3: case 3:
if(outPos + 2 >= bytes.Length) break; if(outPos + 2 >= bytes.Length) break;
bytes[outPos + 2] += (byte)(thisByte & 0x3F); bytes[outPos + 2] += (byte)(thisByte & 0x3F);
outPos += 3; outPos += 3;
break; break;
} }
} }
@@ -404,20 +404,21 @@ namespace Claunia.Encoding
switch(i % 3) switch(i % 3)
{ {
case 0: case 0:
rd50 = (byte)((bytes[index + i] & 0xFC) >> 2); rd50 = (byte)((bytes[index + i] & 0xFC) >> 2);
chars[outPos] = GetChar(rd50); chars[outPos] = GetChar(rd50);
outPos++; outPos++;
break; break;
case 1: case 1:
rd50 = (byte)(((bytes[index + i - 1] & 0x03) << 4) + ((bytes[index + i] & 0xF0) >> 4)); rd50 = (byte)(((bytes[index + i - 1] & 0x03) << 4) + ((bytes[index + i] & 0xF0) >> 4));
chars[outPos] = GetChar(rd50); chars[outPos] = GetChar(rd50);
outPos++; outPos++;
break; break;
case 2: case 2:
rd50 = (byte)(((bytes[index + i - 1] & 0x0F) << 2) + ((bytes[index + i] & 0xC0) >> 6)); rd50 =
chars[outPos] = GetChar(rd50); (byte)(((bytes[index + i - 1] & 0x0F) << 2) + ((bytes[index + i] & 0xC0) >> 6));
chars[outPos + 1] = GetChar((byte)(bytes[index + i] & 0x3F)); chars[outPos] = GetChar(rd50);
outPos += 2; chars[outPos + 1] = GetChar((byte)(bytes[index + i] & 0x3F));
outPos += 2;
break; break;
} }
} }

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class ZX80 : Encoding public class ZX80 : Encoding
{ {
const string _bodyname = "zx80"; const string _bodyname = "zx80";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Sinclair ZX80 character set"; const string _encodingname = "Sinclair ZX80 character set";
const string _headername = "zx80"; const string _headername = "zx80";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = false; const bool readOnly = false;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The ZX80 to Unicode character map. /// The ZX80 to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class ZX81 : Encoding public class ZX81 : Encoding
{ {
const string _bodyname = "zx81"; const string _bodyname = "zx81";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Sinclair ZX81 character set"; const string _encodingname = "Sinclair ZX81 character set";
const string _headername = "zx81"; const string _headername = "zx81";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = false; const bool readOnly = false;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The ZX81 to Unicode character map. /// The ZX81 to Unicode character map.

View File

@@ -33,19 +33,19 @@ namespace Claunia.Encoding
/// </summary> /// </summary>
public class ZXSpectrum : Encoding public class ZXSpectrum : Encoding
{ {
const string _bodyname = "spectrum"; const string _bodyname = "spectrum";
const int _codepage = 0; const int _codepage = 0;
const string _encodingname = "Sinclair ZX Spectrum character set"; const string _encodingname = "Sinclair ZX Spectrum character set";
const string _headername = "spectrum"; const string _headername = "spectrum";
const string _webname = ""; const string _webname = "";
const int _windowsCodepage = 0; const int _windowsCodepage = 0;
const bool browserDisplay = false; const bool browserDisplay = false;
const bool browserSave = false; const bool browserSave = false;
const bool mailNewsDisplay = false; const bool mailNewsDisplay = false;
const bool mailNewsSave = false; const bool mailNewsSave = false;
const bool readOnly = false; const bool readOnly = false;
const bool singleByte = true; const bool singleByte = true;
/// <summary> /// <summary>
/// The ZX Spectrum to Unicode character map. /// The ZX Spectrum to Unicode character map.