Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/oned/code_128_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fn check(contents: &str, hints: &crate::EncodeHints) -> Result<i32> {
CODE_CODE_B_I32 =>
// allows no ascii below 32 (terminal symbols)
{
if c <= 32 {
if c < 32 {
return Err(Exceptions::illegal_argument_with(format!(
"Bad character in input for forced code set B: ASCII value={c}"
)));
Expand Down
17 changes: 17 additions & 0 deletions src/oned/code_128_writer_test_tase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,23 @@ fn testEncodeWithForcedCodeSetFailureCodeSetBBadCharacter() {
.expect("encode");
}

#[test]
fn testEncodeWithForcedCodeSetBSpaces() {
let hints = EncodeHints::default().with(EncodeHintValue::ForceCodeSet("B".to_string()));
for toEncode in [" ", "Hello World 123", " Hello World 123 "] {
let result = WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode");
let decoded = Code128Reader
.decode_row(0, &result.getRow(0), &DecodeHints::default())
.expect("decode");
assert_eq!(toEncode, decoded.getText());
assert_eq!(result.getWidth() as usize, 11 * toEncode.len() + 35 + 10);
let actual = bit_matrix_test_case::matrix_to_string(&result);
assert!(actual.starts_with(&format!("{QUIET_SPACE}{START_CODE_B}")));
}
}

#[test]
#[should_panic]
fn testEncodeWithForcedCodeSetFailureCodeSetCBadCharactersNonNum() {
Expand Down
Loading