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-8")]
    class dvb_iso_8859_8 : 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 0xa2: resultBuilder.Append('¢'); break;
                    case 0xa3: resultBuilder.Append('£'); break;
                    case 0xa4: resultBuilder.Append('¤'); break;
                    case 0xa5: resultBuilder.Append('¥'); break;
                    case 0xa6: resultBuilder.Append('¦'); break;
                    case 0xa7: resultBuilder.Append('§'); break;
                    case 0xa8: resultBuilder.Append('¨'); break;
                    case 0xa9: resultBuilder.Append('©'); break;
                    case 0xaa: resultBuilder.Append('×'); break;
                    case 0xab: resultBuilder.Append('«'); break;
                    case 0xac: resultBuilder.Append('¬'); break;
                    case 0xad: resultBuilder.Append('\u00ad'); break;
                    case 0xae: resultBuilder.Append('®'); break;
                    case 0xaf: resultBuilder.Append('¯'); break;
                    case 0xcd: break;
                    case 0xb4: resultBuilder.Append('´'); break;
                    case 0xd0: break;
                    default:
                        throw new NotImplementedException(String.Format("0x{0:X2}", preprocessed[i]));
                }
            }

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