using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper5.Skyscraper.Text.Encodings
{
    [SkyscraperEncoding("dvb-iso-8859-7")]
    class dvb_iso_8859_7 : SkyscraperBaseEncoding8
    {
        protected override char[] Decrypt(byte[] preprocessed)
        {
            StringBuilder resultBuilder = new StringBuilder();
            for (int i = 0; i < preprocessed.Length; i++)
            {
                if (preprocessed[i] <= 0x7e)
                {
                    AsciiTable.GetAsciiChar(preprocessed[i], resultBuilder);
                    continue;
                }
                switch (preprocessed[i])
                {
                    case 0xa0: resultBuilder.Append('\u00a0'); break;
                    case 0xa1: resultBuilder.Append('ʻ'); break;
                    case 0xa2: resultBuilder.Append('’'); break;
                    case 0xa3: resultBuilder.Append('£'); break;
                    case 0xa4: resultBuilder.Append('€'); break;
                    case 0xa8: resultBuilder.Append('¨'); break;
                    case 0xa9: resultBuilder.Append('©'); break;
                    case 0xab: resultBuilder.Append('«'); break;
                    case 0xad: resultBuilder.Append('\u00AD'); break;
                    case 0xb0: resultBuilder.Append('°'); break;
                    case 0xb4: resultBuilder.Append('´'); break;
                    case 0xb6: resultBuilder.Append('Ά'); break;
                    case 0xb7: resultBuilder.Append('·'); break;
                    case 0xb8: resultBuilder.Append('Έ'); break;
                    case 0xb9: resultBuilder.Append('Ί'); break;
                    case 0xba: resultBuilder.Append('Ί'); break;
                    case 0xbb: resultBuilder.Append('»'); break;
                    case 0xbc: resultBuilder.Append('Ό'); break;
                    case 0xbe: resultBuilder.Append('Ύ'); break;
                    case 0xbf: resultBuilder.Append('Ώ'); break;
                    case 0xc0: resultBuilder.Append('ΐ'); break;
                    case 0xc1: resultBuilder.Append('Α'); break;
                    case 0xc2: resultBuilder.Append('Β'); break;
                    case 0xc3: resultBuilder.Append('Γ'); break;
                    case 0xc4: resultBuilder.Append('Δ'); break;
                    case 0xc5: resultBuilder.Append('Ε'); break;
                    case 0xc6: resultBuilder.Append('Ζ'); break;
                    case 0xc7: resultBuilder.Append('Η'); break;
                    case 0xc8: resultBuilder.Append('Θ'); break;
                    case 0xc9: resultBuilder.Append('Ι'); break;
                    case 0xca: resultBuilder.Append('Κ'); break;
                    case 0xcb: resultBuilder.Append('Λ'); break;
                    case 0xcc: resultBuilder.Append('Μ'); break;
                    case 0xcd: resultBuilder.Append('Ν'); break;
                    case 0xce: resultBuilder.Append('Ξ'); break;
                    case 0xcf: resultBuilder.Append('Ο'); break;
                    case 0xd0: resultBuilder.Append('Π'); break;
                    case 0xd1: resultBuilder.Append('Ρ'); break;
                    case 0xd3: resultBuilder.Append('Σ'); break;
                    case 0xd4: resultBuilder.Append('Τ'); break;
                    case 0xd5: resultBuilder.Append('Υ'); break;
                    case 0xd6: resultBuilder.Append('Φ'); break;
                    case 0xd7: resultBuilder.Append('Χ'); break;
                    case 0xd8: resultBuilder.Append('Ψ'); break;
                    case 0xd9: resultBuilder.Append('Ω'); break;
                    case 0xda: resultBuilder.Append('Ϊ'); break;
                    case 0xdc: resultBuilder.Append('ά'); break;
                    case 0xdd: resultBuilder.Append('έ'); break;
                    case 0xde: resultBuilder.Append('ή'); break;
                    case 0xdf: resultBuilder.Append('ί'); break;
                    case 0xe0: resultBuilder.Append('ΰ'); break;
                    case 0xe1: resultBuilder.Append('α'); break;
                    case 0xe2: resultBuilder.Append('β'); break;
                    case 0xe3: resultBuilder.Append('γ'); break;
                    case 0xe4: resultBuilder.Append('δ'); break;
                    case 0xe5: resultBuilder.Append('ε'); break;
                    case 0xe6: resultBuilder.Append('ζ'); break;
                    case 0xe7: resultBuilder.Append('η'); break;
                    case 0xe8: resultBuilder.Append('θ'); break;
                    case 0xe9: resultBuilder.Append('ι'); break;
                    case 0xea: resultBuilder.Append('κ'); break;
                    case 0xeb: resultBuilder.Append('λ'); break;
                    case 0xec: resultBuilder.Append('μ'); break;
                    case 0xed: resultBuilder.Append('ν'); break;
                    case 0xee: resultBuilder.Append('ξ'); break;
                    case 0xef: resultBuilder.Append('ο'); break;
                    case 0xf0: resultBuilder.Append('π'); break;
                    case 0xf1: resultBuilder.Append('ρ'); break;
                    case 0xf2: resultBuilder.Append('ς'); break;
                    case 0xf3: resultBuilder.Append('σ'); break;
                    case 0xf4: resultBuilder.Append('τ'); break;
                    case 0xf5: resultBuilder.Append('υ'); break;
                    case 0xf6: resultBuilder.Append('φ'); break;
                    case 0xf7: resultBuilder.Append('χ'); break;
                    case 0xf8: resultBuilder.Append('ψ'); break;
                    case 0xf9: resultBuilder.Append('ω'); break;
                    case 0xfa: resultBuilder.Append('ϊ'); break;
                    case 0xfb: resultBuilder.Append('ϋ'); break;
                    case 0xfc: resultBuilder.Append('ό'); break;
                    case 0xfd: resultBuilder.Append('ύ'); break;
                    case 0xfe: resultBuilder.Append('ώ'); break;
                    default:
                        throw new NotImplementedException(String.Format("0x{0:X2}", preprocessed[i]));
                }
            }

            return resultBuilder.ToString().ToCharArray();
        }
    }
}
