Skip to content

Commit

Permalink
fix(lib/io): remove conversion to char
Browse files Browse the repository at this point in the history
remove unnecessary conversion and write byte directly to ctx.io.write, so that complex UTF-8 sequences are output correctly
  • Loading branch information
SaadiSave committed Dec 16, 2023
1 parent c60341c commit 911834b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/src/exec/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use crate::{exec::RtError::*, inst};
use std::io::Read;
use std::io::{Read, Write};

inst!(
/// No-op
Expand Down Expand Up @@ -42,9 +42,9 @@ inst!(
}

#[allow(clippy::cast_possible_truncation)]
let out = x as u8 as char;
let out = x as u8;

write!(ctx.io.write, "{out}")?;
ctx.io.write.write_all(&[out])?;
}
src if src.is_usizeable() => {
let src = ctx.read(src)?;
Expand All @@ -54,9 +54,9 @@ inst!(
}

#[allow(clippy::cast_possible_truncation)]
let out = src as u8 as char;
let out = src as u8;

write!(ctx.io.write, "{out}")?;
ctx.io.write.write_all(&[out])?;
}
_ => return Err(InvalidOperand),
}
Expand Down

0 comments on commit 911834b

Please sign in to comment.