fabienbellanger / escpos-rs

ESC/POS implementation in Rust
https://docs.rs/escpos
Other
27 stars 12 forks source link

Encode ISO8859_15 doesn't work #30

Closed rado31 closed 1 month ago

rado31 commented 1 month ago
  1. OS Window 10
  2. rustup 1.27.1 (54dd3d00f 2024-04-24)
  3. rustc 1.80.1 (3f5fd8dd4 2024-08-06)
  4. cargo 1.80.1 (376290515 2024-07-16)
  5. Cargo.toml
[package]
name = "printer"
version = "0.1.0"
edition = "2021"

[dependencies]
escpos = { version = "0.13.0", features = ["full"] }
rusb = "0.9.4"
  1. Code
    
    use escpos::{
    driver::UsbDriver,
    errors::Result,
    printer::Printer,
    printer_options::PrinterOptions,
    utils::{DebugMode, PageCode, Protocol},
    };

fn main() -> Result<()> { let driver = UsbDriver::open(8137, 8214, None)?;

let options = PrinterOptions::new(Some(PageCode::ISO8859_2), None, 42);

let mut printer = Printer::new(driver, Protocol::default(), Some(options));

printer.debug_mode(Some(DebugMode::Dec)).init()?;

printer.writeln("äöüýşňž")?.feeds(3)?.print_cut()?;

Ok(())

}

ldicocco commented 1 month ago

I don't know if this may be the case, but I've found some printer that by default started in "Chinese mode" and printed Chinese characters instead of most non ASCII chars, no matter the selected page code. In my cases the solution was to add a .custom(&[28_u8, 46])? before printing anything. Maybe it doesn't work anymore as the page code is set in the options. I don't have one of those printers to do the test.

rado31 commented 1 month ago

Unfortunately it doesn't work (with this command: .custom(&[28_u8, 46])?) But it's really no big deal. Despite this, I am very grateful for this project, thanks 🤝