Giter VIP home page Giter VIP logo

Comments (2)

ia0 avatar ia0 commented on July 20, 2024

Hi @QMHTMY ,

Thanks for your question!

I see the concern is only about newline regarding command line tools. So I'll first describe how they work:

  • echo is a tool that prints its arguments, separated by spaces and followed by a newline. If you don't want the newline, you can use echo -n. For example echo abc outputs abc\n (i.e. 6162630a in hexa).
  • data-encoding is a tool that converts strings without extra pretty-printing information, such that it can be used in more complex tools. For example echo -n abc | data-encoding -me -b64 outputs YWJj and not YWJj\n.
  • Shells (like bash) have different ways to show whether a command output contains a newline or not. For example in bash, the prompt is on the same line.

To solve your problems:

  1. If you want a newline after data-encoding output, you can use echo "$(echo -n abc | data-encoding -me -b64)".
  2. To avoid the decoding error, you can remove the invalid newline in the input by using echo -n YWJj | data-encoding -md -b64 (or echo "$(echo -n YWJj | data-encoding -md -b64)" if you want a newline in the output)

Note that you can also ignore newlines when decoding. For example echo YWJj | data-encoding -md -b64 -g$'\n' (the actual syntax to pass a newline to -g depends on your shell).

Hope this helps

from data-encoding.

QMHTMY avatar QMHTMY commented on July 20, 2024

Thank you very much!

from data-encoding.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.