Skip to content

Save and read multiline text as-is #1501

Description

@goforit22123-netizen

I need to save text data to a YAML file exactly as it is, so that another program can subsequently read the file and transmit the data over the network without modification. At the same time, I need to maintain the YAML file's readability.

To preserve readability when saving the text data, I use the YAML::Literal manipulator.

The problem with this manipulator is that it strips all trailing newlines from the text, whereas I need to preserve them. Additionally, when reading the data back as a std::string, a newline character (\n) is appended to the end.

In other words, I need to save text data to YAML file exactly as is and be able to read it back exactly as is. Does yaml-cpp provide any mechanisms for this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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