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 6792113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:55:44+00:00 2026-05-26T17:55:44+00:00

In my C++ program I want to convert a std:string like this: abc €

  • 0

In my C++ program I want to convert a std:string like this:

abc €

to an UTF-8 escape sequence:

abc%20%E2%82%AC

And I need it to be platform independent! All I found has been solutions only working on windows. There must be a solution out there right?

  • 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-05-26T17:55:44+00:00Added an answer on May 26, 2026 at 5:55 pm

    Prior to C++11, there’s no mandated support for UTF-8 in the standard.

    There are two steps here:

    • convert to UTF-8 (unless it’s already in UTF-8)
    • URL-escape the result (update: James Kanze covers this part)

    Neither of them is particularly difficult to write for yourself portably, assuming you know what character encoding the input string uses[*]. Which means other people have done it before, you shouldn’t need to write it yourself. If you search for them separately you might have better luck finding platform-independent code for each step.

    Note there are two different ways to URL-escape a space character, either as + or as %20. Your example uses %20, so if that’s important to you then don’t accidentally use a URL-escape routine that does the other.

    [*] It’s not ISO-Latin-1, since that doesn’t have the Euro sign[**], but it might be Windows CP-1252.

    [**] Unless it’s been added recently. Anyway, your example codes the Euro sign as UTF-8 bytes 0xE2 0x82 0xAC, which represent the Unicode code point 0x20AC, not code point 0x80 which it has in CP1252. So if it was originally a single-byte encoding then clearly an intelligent single-byte-to-unicode-code-point conversion has been applied along the way. You could say there are three steps:

    • convert the std::string to Unicode code points (depends on input encoding).
    • convert the Unicode to UTF-8
    • URL-escape the UTF-8
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sentence say This is my new program I want to convert
I want to convert a string into a date, this is simple. But what
i want to convert an avi file to 3gp using java program. For this
I had written a program in Python 3, but now want to convert it
I just want to know if there is a program that can convert an
I want to make program that encrypts (later decrypts) user inputted string. Here is
We've got a file-based program we want to convert to use a document database,
I want to convert function object to function. I wrote this code, but it
I want to convert PDF to SVG. I have written my own Java program
I have some float values I want to convert to a string, I want

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.