| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
use codec; |
| 8 |
use types::*; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
#[derive(Clone, Copy)] |
| 13 |
pub struct EncoderOnlyUTF8Encoding; |
| 14 |
|
| 15 |
impl Encoding for EncoderOnlyUTF8Encoding { |
| 16 |
fn name(&self) -> &'static str { "encoder-only-utf-8" } |
| 17 |
fn whatwg_name(&self) -> Option<&'static str> { Some("replacement") } |
| 18 |
fn raw_encoder(&self) -> Box<RawEncoder> { codec::utf_8::UTF8Encoding.raw_encoder() } |
| 19 |
fn raw_decoder(&self) -> Box<RawDecoder> { codec::error::ErrorEncoding.raw_decoder() } |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
pub mod x_user_defined { |
| 24 |
#[inline] |
| 25 |
pub fn forward(code: u8) -> u16 { |
| 26 |
0xf700 | (code as u16) |
| 27 |
} |
| 28 |
|
| 29 |
#[inline] |
| 30 |
pub fn backward(code: u32) -> u8 { |
| 31 |
if (code & !0x7f) == 0xf780 {(code & 0xff) as u8} else {0} |
| 32 |
} |
| 33 |
} |
| 34 |
|