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

  • SEARCH
  • Home
  • 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 6864909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:58:18+00:00 2026-05-27T02:58:18+00:00

When using std::codecvt ‘s in method to decode an external byte sequence to an

  • 0

When using std::codecvt‘s in method to decode an external byte sequence to an internal char sequence, is there a situation where the destination buffer of internal chars needs space for more than one internal char?

Here is some code for reference:

// const std::locale& loc;
// mbstate_t state;
// const char *extern_buf_ptr;
// const char *extern_buf_eptr;
const std::codecvt<wchar_t, char, mbstate_t> *pcodecvt = &std::use_facet<std::codecvt<wchar_t, char, mbstate_t> >(loc);

wchar_t intern_char;
wchar_t *tmp;
std::codecvt_base::result in_res = pcodecvt->in(state,
        extern_buf_ptr, extern_buf_eptr, extern_buf_ptr,
        &intern_char, &intern_char + 1, tmp);

This is a simplification of some template code that I have written to decode bytes read individually from a Winsock SOCKET, where the user desires “unbuffered” input. Basically, with each iteration of a loop, a byte is read into the external buffer. The loop terminates when in_res is not std::codecvt_base::partial.

What I am wondering is: Is there a scenario where a call to in() would require space in the destination buffer for more than one internal character? I.e., is there a scenario that would make the above-described loop an infinite loop?

  • 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-27T02:58:18+00:00Added an answer on May 27, 2026 at 2:58 am

    There’s a note in §22.4.1.4.2/3 to that extent:

    basic_filebuf assumes that the mappings from internal to external characters is 1 to N: a codecvt facet that is used by basic_filebuf must be able to translate characters one internal character at a time

    Sounds like any locale that’s good for IO streams is good for your use as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I declare a temporary auto deleted character buffer using std::auto_ptr<char> buffer(new char[n]); then
I am using std::string 's find() method to test if a string is a
I want to sort a vector using std::sort, but my sort method is a
What is the preferred method of using std::rel_ops to add the full set of
I was using std::hash_map<char*,T> and somehow managed to make it work but have now
when copying arrays using std::copy is there a way to check to see if
I'm currently using std::ofstream as follows: std::ofstream outFile; outFile.open(output_file); Then I attempt to pass
Right now I am using std::pair to represent a 2d point in c++. However,
I'm using std::map to store a lot of elements (pairs of elements) and I
In C++ using std::list , removing a member is a simple matter of erasing

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.