(&self, ctx: Ctx<'js>, bytes: ObjectBytes<'js>)
| 54 | } |
| 55 | |
| 56 | pub fn decode(&self, ctx: Ctx<'js>, bytes: ObjectBytes<'js>) -> Result<String> { |
| 57 | let bytes = bytes.as_bytes(&ctx)?; |
| 58 | let start_pos = if !self.ignore_bom { |
| 59 | match bytes.get(..3) { |
| 60 | Some([0xFF, 0xFE, ..]) | Some([0xFE, 0xFF, ..]) => 2, |
| 61 | Some([0xEF, 0xBB, 0xBF]) => 3, |
| 62 | _ => 0, |
| 63 | } |
| 64 | } else { |
| 65 | 0 |
| 66 | }; |
| 67 | |
| 68 | self.encoder |
| 69 | .encode_to_string(&bytes[start_pos..], !self.fatal) |
| 70 | .or_throw_type(&ctx, "") |
| 71 | } |
| 72 | } |
no test coverage detected