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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:44:46+00:00 2026-05-11T22:44:46+00:00

So I want to use SetThreadLocale to set a threads codepage to UTF8. Up

  • 0

So I want to use SetThreadLocale to set a threads codepage to UTF8. Up to now, I’ve been using the second parameter of atl string conversion macros like “CT2A(szBUF, CP_UTF8)” to do this. But I want to be able to set the thread codepage once in the beginning with SetThreadLocale() and never have to use the second parameter of the conversion macro again.

How do I do this? SetThreadLocale won’t take a code page parameter like CP_UTF8, just an LCID. What parameters should I be feeding SetThreadLocale to achieve this??

Keep in mind, I have no particular language in mind. The strings I get could be Japanese, Korean, English Etc. So far, I’m having no problems with this mix of strings when specifying CP_UTF8 as the second parameter of a conversion macro. You may ask “well then why not just keep using the second parameter”. Answer, “because it can be easily forgotten by team members working on the code. It would be nice if it would just work correctly using the default 1 parameter version of the conversion macro.”

  • 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-11T22:44:46+00:00Added an answer on May 11, 2026 at 10:44 pm

    SetThreadLocale expects a language identifier, but UTF-8 is not a language identifier – it’s a Unicode encoding. One of the purposes of the land ID is to tell the system how to treat ANSI text in the range 128-255. Given a real language, its code page will be used when dealing with such characters. UTF-8, OTOH, is a compressed representation of Unicode text. In order to create UTF-8 text, your input has to be Unicode. Given ANSI text, you just won’t know how to convert the upper range of characters. This is way when done “manually”, in order to convert ANSI to UTF-8 you have to first use MultiByteToWideChar with a specified codepage, and only then can you convert the resulting Unicode string to UTF-8.

    Now, back to your question – I would go another way. If the additional codepage param bugs you that much, make a macro that will hide it or so (or inherit the CT2A class and have the second param fixed).

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

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Maybe it would help if you thought of the selenium… May 12, 2026 at 12:51 am
  • Editorial Team
    Editorial Team added an answer In Objective-C, all object references are pointers, so you always… May 12, 2026 at 12:50 am
  • Editorial Team
    Editorial Team added an answer from myObjectList in myObjectDictionary.Values from myObject in myObjectList.Distinct() group myObject… May 12, 2026 at 12:50 am

Related Questions

So, I want to use jquery to set the text of a button, depending
I want to use jquery-ui widgets and so I am including jquery.ui.js. Would I
I want to escape a DOS filename so I can use it with sed.
I want to use the jQuery accordion tool for a form i'm building so
I want to use git to allow me to work on several features in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.