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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:59:38+00:00 2026-05-13T15:59:38+00:00

wcstombs documentation says, it converts the sequence of wide-character codes to multibyte string. But

  • 0

wcstombs documentation says, it “converts the sequence of wide-character codes to multibyte string”. But it never says what is a “wide-character”.

Is it implicit, like say it converts utf-16 to utf-8 or the conversion is defined by some environment variable?

Also what is the typical use case of wcstombs?

  • 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-13T15:59:39+00:00Added an answer on May 13, 2026 at 3:59 pm

    You use the setlocale() standard function with the LC_CTYPE (or LC_ALL) category to set the mapping the library uses between wchar_t characters and multibyte characters. The actual locale name passed to setlocale() is implementation defined, so you’ll need to look it up in your compiler’s docs.

    For example, with MSVC you might use

    setlocale( LC_ALL, ".1252" );
    

    to set the C runtime to use codepage 1252 as the multibyte character set. Note that MSVC docs explicitly indicates that the locale cannot be set to UTF-7 or UTF8 for the multibyte character sets:

    The set of available languages, country/region codes, and code pages includes all those supported by the Win32 NLS API except code pages that require more than two bytes per character, such as UTF-7 and UTF-8. If you provide a code page like UTF-7 or UTF-8, setlocale will fail, returning NULL.

    The “wide-character” wchar_t type is intended to be able to support any character set the system supports – the standard doesn’t define the size of a wchar_t type (it could be as small as a char or any of the larger integer types). On Windows it’s the system’s ‘internal’ Unicode encoding, which is UTF-16 (UCS-2 before WinXP). Honestly, I can’t find a direct quote on that in the MSVC docs, though. Strictly speaking, the implementation should call this out, but I can’t find it.

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

Sidebar

Related Questions

Here is a C code that converts a wchar_t* string into a char* string
I'm not quite pro with encodings, but here's what I think I know (though
I want to send my C# string to a C++ DLL function. I have
The question is in the title... I searched but couldn't find anything. Edit: I
as the question says, what would be a suitable template function to convert wstring
What is the difference between WideCharToMultiByte() and wcstombs() When to use which one?
I have a problem with wchar_t* to char* conversion. I'm getting a wchar_t* string
I have to map containers: map<string, char *> mOServs; map<LPWCH, int> mymap; I do
Some time ago, I found a clever trick on stackoverflow that showed a way
I've been experiencing a problem with the Winsock2's function send(). No matter what data

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.