1 module ithox.qrcode.common.characterseteci; 2 3 /// Character set constants. 4 enum CharacterEnun : int 5 { 6 CP437 = 0, 7 ISO8859_1 = 1, 8 ISO8859_2 = 4, 9 ISO8859_3 = 5, 10 ISO8859_4 = 6, 11 ISO8859_5 = 7, 12 ISO8859_6 = 8, 13 ISO8859_7 = 9, 14 ISO8859_8 = 10, 15 ISO8859_9 = 11, 16 ISO8859_10 = 12, 17 ISO8859_11 = 13, 18 ISO8859_12 = 14, 19 ISO8859_13 = 15, 20 ISO8859_14 = 16, 21 ISO8859_15 = 17, 22 ISO8859_16 = 18, 23 SJIS = 20, 24 CP1250 = 21, 25 CP1251 = 22, 26 CP1252 = 23, 27 CP1256 = 24, 28 UNICODE_BIG_UNMARKED = 25, 29 UTF8 = 26, 30 ASCII = 27, 31 BIG5 = 28, 32 GB18030 = 29, 33 EUC_KR = 30, 34 } 35 36 /** 37 * Encapsulates a Character Set ECI, according to "Extended Channel 38 * Interpretations" 5.3.1.1 of ISO 18004. 39 */ 40 class CharacterSetEci 41 { 42 43 protected CharacterEnun _c; 44 ///Map between character names and their ECI values. 45 protected enum CharacterEnun[string] nameToEci = [ 46 "ISO-8859-1" : CharacterEnun.ISO8859_1, "ISO-8859-2" 47 : CharacterEnun.ISO8859_2, "ISO-8859-3" : CharacterEnun.ISO8859_3, 48 "ISO-8859-4" : CharacterEnun.ISO8859_4, "ISO-8859-5" 49 : CharacterEnun.ISO8859_5, "ISO-8859-6" : CharacterEnun.ISO8859_6, 50 "ISO-8859-7" : CharacterEnun.ISO8859_7, "ISO-8859-8" 51 : CharacterEnun.ISO8859_8, "ISO-8859-9" : CharacterEnun.ISO8859_9, 52 "ISO-8859-10" : CharacterEnun.ISO8859_10, "ISO-8859-11" 53 : CharacterEnun.ISO8859_11, "ISO-8859-12" 54 : CharacterEnun.ISO8859_12, "ISO-8859-13" : CharacterEnun.ISO8859_13, 55 "ISO-8859-14" : CharacterEnun.ISO8859_14, "ISO-8859-15" 56 : CharacterEnun.ISO8859_15, "ISO-8859-16" : CharacterEnun.ISO8859_16, 57 "SHIFT-JIS" : CharacterEnun.SJIS, "WINDOWS-1250" 58 : CharacterEnun.CP1250, "WINDOWS-1251" : CharacterEnun.CP1251, 59 "WINDOWS-1252" : CharacterEnun.CP1252, "WINDOWS-1256" 60 : CharacterEnun.CP1256, "UTF-16BE" : CharacterEnun.UNICODE_BIG_UNMARKED, 61 "UTF-8" : CharacterEnun.UTF8, "ASCII" 62 : CharacterEnun.ASCII, "GBK" : CharacterEnun.GB18030, "EUC-KR" 63 : CharacterEnun.EUC_KR, 64 ]; 65 66 this(CharacterEnun s) 67 { 68 this._c = s; 69 70 } 71 72 public @property CharacterEnun eci() 73 { 74 return this._c; 75 } 76 77 public static CharacterSetEci getCharacterSetEciByName(string enc) 78 { 79 //return nameToEci.get(enc, CharacterEnun.UTF8); 80 return new CharacterSetEci(nameToEci.get(enc, CharacterEnun.UTF8)); 81 } 82 83 }