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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:12:07+00:00 2026-06-14T15:12:07+00:00

There are several functions that convert ANSI to Unicode and vice versa. Here are

  • 0

There are several functions that convert ANSI to Unicode and vice versa. Here are those functions WideCharToMultiByte, MultiByteToWideChar, A2W, W2A.

Now I don’t understand how A2W and W2A work. The thing is that when you convert something to another thing than you should have two sets set A and set B so that each element in set A is mapped to one and only one element in set B uniquely. Regarding this there are several problems:

  1. ANSI is one byte and UNICODE is at least 2 byte which means not all elements in UNICODE set can be mapped to ANSI uniquely.

  2. Set ANSI and set Unicode are not strictly defined. I mean there are different encoding for both.

Hereby, my question: how we can convert them and be sure that we have not spoiled the data?

  • 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-14T15:12:08+00:00Added an answer on June 14, 2026 at 3:12 pm

    As others have mentioned, there is no such character set as ‘ANSI’. Unfortunately, the Windows API refers to CP_ACP, the ‘ANSI code page’, which refers to one of several character sets depending on which non-unicode locale is selected on your machine.

    That said, with regards to your original question, no, you cannot always round trip between CP_ACP and a unicode encoding. There’s no equivalent for あ in CP_ACP on an English-locale windows system, for example.

    When this happens, WideCharToMultiByte will replace the character that has no equivalent with lpDefaultChar, if set, and set *lpUsedDefaultChar to true. You can pass a pointer to a boolean variable in lpUsedDefaultChar and check it after calling to see if your string contained non-translatable characters. The other direction, MultiByteToWideChar never fails as long as the input is valid in your local codepage, however. To try to detect invalid text, pass in the MB_ERR_INVALID_CHARS flag and check for an error – that said, just because the text is in some other codepage, doesn’t mean you’ll get an error from it (it’s hard to tell if the text is actually invalid, or if it’s merely gibberish).

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

Sidebar

Related Questions

There are several threads on this here at SO but I didn't find one
There are several other questions about this topic that I have gone through, but
There are several places on the internet that talk about having multy key dictionary
There are several resources out there that explain how the sandbox in Chrome works
There are several properties on List<T> that seem to be related to number of
The code function that I'm specifically talking about is getCount(). There are several other
I want to write several functions that are only different in the types of
I have an algorithm that calls several functions to process its data. Each of
There are several variant questions on this on SO, but I did not find
There are several ways google throws at me for checking if a file is

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.