encoding/codec/
whatwg.rs
1use codec;
8use types::*;
9
10#[derive(Clone, Copy)]
13pub struct EncoderOnlyUTF8Encoding;
14
15impl Encoding for EncoderOnlyUTF8Encoding {
16 fn name(&self) -> &'static str { "encoder-only-utf-8" }
17 fn whatwg_name(&self) -> Option<&'static str> { Some("replacement") } 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
22pub 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