Skip to content

How to print caret(^) as text using zebra-zpl gem? #84

@a-kushnir

Description

@a-kushnir

The following code:

label = Zebra::Zpl::Label.new print_speed: 6
label << Zebra::Zpl::Text.new(
  data: "Line 1",
  position: [100, 100],
  width: 400,
  font_size: Zebra::Zpl::FontSize::SIZE_2
)
label << Zebra::Zpl::Text.new(
  data: "Line 2: ^XZ^XAZ-1234", # This line should be escaped
  position: [100, 200],
  width: 400,
  font_size: Zebra::Zpl::FontSize::SIZE_2
)
io = StringIO.new
label.dump_contents(io)
puts io.string

generates the following text:

^XA^LH0,0^LS10^PR6
^FWN^CF0,22^CI28^FO100,100^FB400,4,,L,
^FDLine 1
^FWN^CF0,22^CI28^FO100,200^FB400,4,,L,
^FDLine 2: ^XZ^XAZ-1234^FS
^PQ1^XZ

but it should be:

^XA^LH0,0^LS10^PR6
^FWN^CF0,22^CI28^FO100,100^FB400,4,,L,
^FDLine 1
^FS^FWN^CF0,22^CI28^FO100,200^FB400,4,,L,
^FH^FDLine 2: _5EXZ_5EXAZ-1234
^PQ1^XZ

See ^FH Command in Zebra Programming Language (ZPL): https://stackoverflow.com/questions/16821629/how-to-print-a-tilde-in-zebra-programming-language-zpl)](https://www.zebra.com/content/dam/zebra_new_ia/en-us/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf#page=189

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions