Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8774289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:31:37+00:00 2026-06-13T18:31:37+00:00

I need to convert an input string which can contain \r\n as part of

  • 0

I need to convert an input string which can contain \r\n as part of string. For example as given below

\r\n Content-type: text/plain; charset=iso-8859-1 \r\n Subject: Test Subject \r\n\r\n Test Message 

Now while sending this string over HTTP Post data I need to convert \r\n to percentile encoding. But when I use curl_easy_escape function it understand \r\n as different characters and encode incorrectly. So to avoid such error I need to convert \r\n in above string as carriage return and newline so that the buffer get converted correctly by curl_easy_escape() function.
I tried using sstream object, sprintf and sscanf with the buffer (as the buffer is an std::string object) but didn’t help out much. Basically I want to convert the buffer as below

Content-type: text/plain; charset=iso-8859-1
Subject: Test Subject

Test Message

So that when we pass this buffer to curl_easy_escape it encodes properly.
So any pointers in this regard will be very helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:31:39+00:00Added an answer on June 13, 2026 at 6:31 pm

    You can use std::string::find and std::string::replace in a loop to do it:

    std::string input = "\\r\\n Content-type: text/plain; charset=iso-8859-1 \\r\\n Subject: Test Subject \\r\\n\\r\\n Test Message";
    
    std::string::size_type pos = 0;
    while ((pos = input.find("\\r\\n", pos)) != std::string::npos)
    {
        input.replace(pos, 4, "\r\n");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function that can print Turkish characters. public String convert(String input) {
I need the Perl regex to parse plain text input and convert all links
I need to convert text file to the String, which, finally, I should put
I need to convert string to float, but there can be different input string
I basically need to get user input: gets.chomp(input?) And then to convert the given
Need help to convert code from asp control to input type to fetch file
I have a string -4.00 % which I need to convert to a decimal
I need to create while running a flow chart for string input which I
I need to convert a String to enum. I followed the idea in String
I need to convert a string vector in a simple string. I do not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.