Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support conversion of \n to ZPL newline characters \\& #15

Open
itsmattking opened this issue Aug 21, 2024 · 1 comment
Open

Support conversion of \n to ZPL newline characters \\& #15

itsmattking opened this issue Aug 21, 2024 · 1 comment

Comments

@itsmattking
Copy link
Collaborator

Create an extension function of String perhaps?

@jbduncan
Copy link

jbduncan commented Aug 21, 2024

I can see at least two options:

  1. Automatically translate \n into \\& behind the scenes, as part of the build() function perhaps.
    • Pro: This would let us use Kotlin multiline blocks and trimIndent().
    • Cons:
      • It's less explicit what's happening.
      • If \n means something useful to the printer, we'd need a workaround to support it.
  2. Make a function like ZplBuilder.appendLine(), à la https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/append-line.html#appendline.
    • Pro: It's explicit what's happening.
    • Con: We wouldn't be able to use Kotlin multiline blocks.

itsmattking added a commit that referenced this issue Sep 7, 2024
In FieldData, add an option to replace newlines `\n`
with ZPL newline representation `\&`.

Also update FieldBlock extension to use this option
so that any usage of fieldBlock will automatically
replace newlines.
itsmattking added a commit that referenced this issue Sep 20, 2024
- Make newline replacement non-optional. It is very unlikely
we want to allow newline `\n` characters in field data as
this breaks ZPL output.
- Remove explicit use of `LinkedHashMap` as the `parameters` type
in favour of using just `Map`.
- Add helper `addParameters` to make explicit that we want a `LinkedHashMap`
to be used when adding parameters. This is to ensure key entry order is preserved.
itsmattking added a commit that referenced this issue Sep 20, 2024
[#15] Replace newlines with ZPL equivalent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants