import Exception from './../Exception' ; export const enum CharacterSetValueIdentifiers { Cp437 , ISO8859_1 , ISO8859_2 , ISO8859_3 , ISO8859_4 , ISO8859_5 , ISO8859_6 , ISO8859_7 , ISO8859_8 , ISO8859_9 , ISO8859_10 , ISO8859_11 , ISO8859_13 , ISO8859_14 , ISO8859_15 , ISO8859_16 , SJIS , Cp1250 , Cp1251 , Cp1252 , Cp1256 , UnicodeBigUnmarked , UTF8 , ASCII , Big5 , GB18030 , EUC_KR } author Sean Owen
  export default class CharacterSetECI { private static VALUE_IDENTIFIER_TO_ECI = new Map < number , CharacterSetECI > ( ) ; private static VALUES_TO_ECI = new Map < number , CharacterSetECI > ( ) ; private static NAME_TO_ECI = new Map < string , CharacterSetECI > ( ) ; public static readonly Cp437 = new CharacterSetECI ( CharacterSetValueIdentifiers . Cp437 , Int32Array . from ( [ 0 , 2 ] ) , 'Cp437' ) ; public static readonly ISO8859_1 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_1 , Int32Array . from ( [ 1 , 3 ] ) , 'ISO-8859-1' , 'ISO88591' , 'ISO8859_1' ) ; public static readonly ISO8859_2 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_2 , 4 , 'ISO-8859-2' , 'ISO88592' , 'ISO8859_2' ) ; public static readonly ISO8859_3 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_3 , 5 , 'ISO-8859-3' , 'ISO88593' , 'ISO8859_3' ) ; public static readonly ISO8859_4 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_4 , 6 , 'ISO-8859-4' , 'ISO88594' , 'ISO8859_4' ) ; public static readonly ISO8859_5 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_5 , 7 , 'ISO-8859-5' , 'ISO88595' , 'ISO8859_5' ) ; public static readonly ISO8859_6 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_6 , 8 , 'ISO-8859-6' , 'ISO88596' , 'ISO8859_6' ) ; public static readonly ISO8859_7 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_7 , 9 , 'ISO-8859-7' , 'ISO88597' , 'ISO8859_7' ) ; public static readonly ISO8859_8 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_8 , 10 , 'ISO-8859-8' , 'ISO88598' , 'ISO8859_8' ) ; public static readonly ISO8859_9 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_9 , 11 , 'ISO-8859-9' , 'ISO88599' , 'ISO8859_9' ) ; public static readonly ISO8859_10 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_10 , 12 , 'ISO-8859-10' , 'ISO885910' , 'ISO8859_10' ) ; public static readonly ISO8859_11 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_11 , 13 , 'ISO-8859-11' , 'ISO885911' , 'ISO8859_11' ) ; public static readonly ISO8859_13 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_13 , 15 , 'ISO-8859-13' , 'ISO885913' , 'ISO8859_13' ) ; public static readonly ISO8859_14 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_14 , 16 , 'ISO-8859-14' , 'ISO885914' , 'ISO8859_14' ) ; public static readonly ISO8859_15 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_15 , 17 , 'ISO-8859-15' , 'ISO885915' , 'ISO8859_15' ) ; public static readonly ISO8859_16 = new CharacterSetECI ( CharacterSetValueIdentifiers . ISO8859_16 , 18 , 'ISO-8859-16' , 'ISO885916' , 'ISO8859_16' ) ; public static readonly SJIS = new CharacterSetECI ( CharacterSetValueIdentifiers . SJIS , 20 , 'SJIS' , 'Shift_JIS' ) ; public static readonly Cp1250 = new CharacterSetECI ( CharacterSetValueIdentifiers . Cp1250 , 21 , 'Cp1250' , 'windows-1250' ) ; public static readonly Cp1251 = new CharacterSetECI ( CharacterSetValueIdentifiers . Cp1251 , 22 , 'Cp1251' , 'windows-1251' ) ; public static readonly Cp1252 = new CharacterSetECI ( CharacterSetValueIdentifiers . Cp1252 , 23 , 'Cp1252' , 'windows-1252' ) ; public static readonly Cp1256 = new CharacterSetECI ( CharacterSetValueIdentifiers . Cp1256 , 24 , 'Cp1256' , 'windows-1256' ) ; public static readonly UnicodeBigUnmarked = new CharacterSetECI ( CharacterSetValueIdentifiers . UnicodeBigUnmarked , 25 , 'UnicodeBigUnmarked' , 'UTF-16BE' , 'UnicodeBig' ) ; public static readonly UTF8 = new CharacterSetECI ( CharacterSetValueIdentifiers . UTF8 , 26 , 'UTF8' , 'UTF-8' ) ; public static readonly ASCII = new CharacterSetECI ( CharacterSetValueIdentifiers . ASCII , Int32Array . from ( [ 27 , 170 ] ) , 'ASCII' , 'US-ASCII' ) ; public static readonly Big5 = new CharacterSetECI ( CharacterSetValueIdentifiers . Big5 , 28 , 'Big5' ) ; public static readonly GB18030 = new CharacterSetECI ( CharacterSetValueIdentifiers . GB18030 , 29 , 'GB18030' , 'GB2312' , 'EUC_CN' , 'GBK' ) ; public static readonly EUC_KR = new CharacterSetECI ( CharacterSetValueIdentifiers . EUC_KR , 30 , 'EUC_KR' , 'EUC-KR' ) ; public values : Int32Array ; public otherEncodingNames : string [ ] ; public constructor ( public valueIdentifier , valuesParam , public name , ... otherEncodingNames ) { if ( typeof valuesParam === 'number' ) { this . values = Int32Array . from ( [ valuesParam ] ) ; } else { this . values = valuesParam ; } this . otherEncodingNames = otherEncodingNames ; CharacterSetECI . VALUE_IDENTIFIER_TO_ECI . set ( valueIdentifier , this ) ; CharacterSetECI . NAME_TO_ECI . set ( name , this ) ; const values = this . values ; for ( let i = 0 , length = values . length ; i !== length ; i ++ ) { const v = values [ i ] ; CharacterSetECI . VALUES_TO_ECI . set ( v , this ) ; } for ( const otherName of otherEncodingNames ) { CharacterSetECI . NAME_TO_ECI . set ( otherName , this ) ; } } public getValueIdentifier ( ) { return this . valueIdentifier ; } public getName ( ) { return this . name ; } public getValue ( ) { return this . values [ 0 ] ; } param value return { code throws public static getCharacterSetECIByValue ( value ) { if ( value < 0 || value >= 900 ) { throw new Exception ( Exception . FormatException , 'incorect value' ) ; } const characterSet = CharacterSetECI . VALUES_TO_ECI . get ( value ) ; if ( undefined === characterSet ) { throw new Exception ( Exception . FormatException , 'incorect value' ) ; } return characterSet ; } param name return public static getCharacterSetECIByName ( name ) { const characterSet = CharacterSetECI . NAME_TO_ECI . get ( name ) ; if ( undefined === characterSet ) { throw new Exception ( Exception . FormatException , 'incorect value' ) ; } return characterSet ; } public equals ( o ) { if ( ! ( o instanceof CharacterSetECI ) ) { return false ; } const other = o as CharacterSetECI ; return this . getName ( ) === other . getName ( ) ; } }