| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
use index_singlebyte as index; |
| 8 |
use codec; |
| 9 |
use types::EncodingRef; |
| 10 |
|
| 11 |
macro_rules! unique( |
| 12 |
($(#[$attr:meta])* var=$var:ident, mod=$($module:ident)::+, val=$val:ident) => ( |
| 13 |
unique!($(#[$attr])* var=$var, mod=$($module)::+, ty=$val, val=$val); |
| 14 |
); |
| 15 |
($(#[$attr:meta])* var=$var:ident, mod=$($module:ident)::+, ty=$ty:ident, val=$val:ident) => ( |
| 16 |
$(#[$attr])* pub const $var: &'static $($module)::+::$ty = &$($module)::+::$val; |
| 17 |
); |
| 18 |
); |
| 19 |
|
| 20 |
macro_rules! singlebyte( |
| 21 |
($(#[$attr:meta])* var=$var:ident, mod=$($module:ident)::+, name=$name:expr) => ( |
| 22 |
singlebyte!($(#[$attr])* var=$var, mod=$($module)::+, name=$name, whatwg=None); |
| 23 |
); |
| 24 |
($(#[$attr:meta])* var=$var:ident, mod=$($module:ident)::+, name|whatwg=$name:expr) => ( |
| 25 |
singlebyte!($(#[$attr])* var=$var, mod=$($module)::+, name=$name, whatwg=Some($name)); |
| 26 |
); |
| 27 |
($(#[$attr:meta])* var=$var:ident, mod=$($module:ident)::+, |
| 28 |
name=$name:expr, whatwg=$whatwg:expr) => ( |
| 29 |
$(#[$attr])* pub const $var: &'static codec::singlebyte::SingleByteEncoding = |
| 30 |
&codec::singlebyte::SingleByteEncoding { |
| 31 |
name: $name, |
| 32 |
whatwg_name: $whatwg, |
| 33 |
index_forward: $($module)::+::forward, |
| 34 |
index_backward: $($module)::+::backward, |
| 35 |
}; |
| 36 |
) |
| 37 |
); |
| 38 |
|
| 39 |
unique!(var=ERROR, mod=codec::error, val=ErrorEncoding); |
| 40 |
unique!(var=ASCII, mod=codec::ascii, val=ASCIIEncoding); |
| 41 |
singlebyte!(var=IBM866, mod=index::ibm866, name|whatwg="ibm866"); |
| 42 |
singlebyte!(var=ISO_8859_1, mod=codec::singlebyte::iso_8859_1, name="iso-8859-1"); |
| 43 |
singlebyte!(var=ISO_8859_2, mod=index::iso_8859_2, name|whatwg="iso-8859-2"); |
| 44 |
singlebyte!(var=ISO_8859_3, mod=index::iso_8859_3, name|whatwg="iso-8859-3"); |
| 45 |
singlebyte!(var=ISO_8859_4, mod=index::iso_8859_4, name|whatwg="iso-8859-4"); |
| 46 |
singlebyte!(var=ISO_8859_5, mod=index::iso_8859_5, name|whatwg="iso-8859-5"); |
| 47 |
singlebyte!(var=ISO_8859_6, mod=index::iso_8859_6, name|whatwg="iso-8859-6"); |
| 48 |
singlebyte!(var=ISO_8859_7, mod=index::iso_8859_7, name|whatwg="iso-8859-7"); |
| 49 |
singlebyte!(var=ISO_8859_8, mod=index::iso_8859_8, name|whatwg="iso-8859-8"); |
| 50 |
singlebyte!(var=ISO_8859_10, mod=index::iso_8859_10, name|whatwg="iso-8859-10"); |
| 51 |
singlebyte!(var=ISO_8859_13, mod=index::iso_8859_13, name|whatwg="iso-8859-13"); |
| 52 |
singlebyte!(var=ISO_8859_14, mod=index::iso_8859_14, name|whatwg="iso-8859-14"); |
| 53 |
singlebyte!(var=ISO_8859_15, mod=index::iso_8859_15, name|whatwg="iso-8859-15"); |
| 54 |
singlebyte!(var=ISO_8859_16, mod=index::iso_8859_16, name|whatwg="iso-8859-16"); |
| 55 |
singlebyte!(var=KOI8_R, mod=index::koi8_r, name|whatwg="koi8-r"); |
| 56 |
singlebyte!(var=KOI8_U, mod=index::koi8_u, name|whatwg="koi8-u"); |
| 57 |
singlebyte!(var=MAC_ROMAN, mod=index::macintosh, name="mac-roman", whatwg=Some("macintosh")); |
| 58 |
singlebyte!(var=WINDOWS_874, mod=index::windows_874, name|whatwg="windows-874"); |
| 59 |
singlebyte!(var=WINDOWS_1250, mod=index::windows_1250, name|whatwg="windows-1250"); |
| 60 |
singlebyte!(var=WINDOWS_1251, mod=index::windows_1251, name|whatwg="windows-1251"); |
| 61 |
singlebyte!(var=WINDOWS_1252, mod=index::windows_1252, name|whatwg="windows-1252"); |
| 62 |
singlebyte!(var=WINDOWS_1253, mod=index::windows_1253, name|whatwg="windows-1253"); |
| 63 |
singlebyte!(var=WINDOWS_1254, mod=index::windows_1254, name|whatwg="windows-1254"); |
| 64 |
singlebyte!(var=WINDOWS_1255, mod=index::windows_1255, name|whatwg="windows-1255"); |
| 65 |
singlebyte!(var=WINDOWS_1256, mod=index::windows_1256, name|whatwg="windows-1256"); |
| 66 |
singlebyte!(var=WINDOWS_1257, mod=index::windows_1257, name|whatwg="windows-1257"); |
| 67 |
singlebyte!(var=WINDOWS_1258, mod=index::windows_1258, name|whatwg="windows-1258"); |
| 68 |
singlebyte!(var=MAC_CYRILLIC, mod=index::x_mac_cyrillic, |
| 69 |
name="mac-cyrillic", whatwg=Some("x-mac-cyrillic")); |
| 70 |
unique!(var=UTF_8, mod=codec::utf_8, val=UTF8Encoding); |
| 71 |
unique!(var=UTF_16LE, mod=codec::utf_16, ty=UTF16LEEncoding, val=UTF_16LE_ENCODING); |
| 72 |
unique!(var=UTF_16BE, mod=codec::utf_16, ty=UTF16BEEncoding, val=UTF_16BE_ENCODING); |
| 73 |
unique!(var=WINDOWS_949, mod=codec::korean, val=Windows949Encoding); |
| 74 |
unique!(var=EUC_JP, mod=codec::japanese, val=EUCJPEncoding); |
| 75 |
unique!(var=WINDOWS_31J, mod=codec::japanese, val=Windows31JEncoding); |
| 76 |
unique!(var=ISO_2022_JP, mod=codec::japanese, val=ISO2022JPEncoding); |
| 77 |
unique!(var=GBK, mod=codec::simpchinese, ty=GBKEncoding, val=GBK_ENCODING); |
| 78 |
unique!(var=GB18030, mod=codec::simpchinese, ty=GB18030Encoding, val=GB18030_ENCODING); |
| 79 |
unique!(var=HZ, mod=codec::simpchinese, val=HZEncoding); |
| 80 |
unique!(var=BIG5_2003, mod=codec::tradchinese, val=BigFive2003Encoding); |
| 81 |
|
| 82 |
pub mod whatwg { |
| 83 |
use index_singlebyte as index; |
| 84 |
use codec; |
| 85 |
|
| 86 |
singlebyte!(var=X_USER_DEFINED, mod=codec::whatwg::x_user_defined, |
| 87 |
name="pua-mapped-binary", whatwg=Some("x-user-defined")); |
| 88 |
singlebyte!(var=ISO_8859_8_I, mod=index::iso_8859_8, name|whatwg="iso-8859-8-i"); |
| 89 |
unique!(var=REPLACEMENT, mod=codec::whatwg, val=EncoderOnlyUTF8Encoding); |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
pub fn encodings() -> &'static [EncodingRef] { |
| 94 |
|
| 95 |
const ENCODINGS: &'static [EncodingRef] = &[ |
| 96 |
ERROR, |
| 97 |
ASCII, |
| 98 |
IBM866, |
| 99 |
ISO_8859_1, |
| 100 |
ISO_8859_2, |
| 101 |
ISO_8859_3, |
| 102 |
ISO_8859_4, |
| 103 |
ISO_8859_5, |
| 104 |
ISO_8859_6, |
| 105 |
ISO_8859_7, |
| 106 |
ISO_8859_8, |
| 107 |
ISO_8859_10, |
| 108 |
ISO_8859_13, |
| 109 |
ISO_8859_14, |
| 110 |
ISO_8859_15, |
| 111 |
ISO_8859_16, |
| 112 |
KOI8_R, |
| 113 |
KOI8_U, |
| 114 |
MAC_ROMAN, |
| 115 |
WINDOWS_874, |
| 116 |
WINDOWS_1250, |
| 117 |
WINDOWS_1251, |
| 118 |
WINDOWS_1252, |
| 119 |
WINDOWS_1253, |
| 120 |
WINDOWS_1254, |
| 121 |
WINDOWS_1255, |
| 122 |
WINDOWS_1256, |
| 123 |
WINDOWS_1257, |
| 124 |
WINDOWS_1258, |
| 125 |
MAC_CYRILLIC, |
| 126 |
UTF_8, |
| 127 |
UTF_16LE, |
| 128 |
UTF_16BE, |
| 129 |
WINDOWS_949, |
| 130 |
EUC_JP, |
| 131 |
WINDOWS_31J, |
| 132 |
ISO_2022_JP, |
| 133 |
GBK, |
| 134 |
GB18030, |
| 135 |
HZ, |
| 136 |
BIG5_2003, |
| 137 |
whatwg::X_USER_DEFINED, |
| 138 |
whatwg::ISO_8859_8_I, |
| 139 |
whatwg::REPLACEMENT, |
| 140 |
]; |
| 141 |
ENCODINGS |
| 142 |
} |
| 143 |
|