high level encoder builds

This commit is contained in:
Henry Schimke
2022-10-27 17:45:32 -05:00
parent fb6dfac670
commit 7ac08007e7
6 changed files with 45 additions and 44 deletions

View File

@@ -28,7 +28,7 @@ impl Encoder for Base256Encoder {
}
fn encode(&self, context: &mut super::EncoderContext) -> Result<(), crate::Exceptions> {
let buffer = String::new();
let mut buffer = String::new();
buffer.push('\0'); //Initialize length field
while context.hasMoreCharacters() {
let c = context.getCurrentChar();
@@ -55,7 +55,7 @@ impl Encoder for Base256Encoder {
if context.hasMoreCharacters() || mustPad {
if dataCount <= 249 {
buffer.replace_range(0..1, &char::from_u32(dataCount as u32).unwrap().to_string());
} else if dataCount as u8 <= 1555 {
} else if dataCount <= 1555 {
buffer.replace_range(
0..1,
&char::from_u32(((dataCount as u32 / 250) + 249))