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