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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:21:13+00:00 2026-05-15T18:21:13+00:00

Given: ASP.Net application which uses a legacy COM library legacy COM library which is

  • 0

Given:
ASP.Net application which uses a legacy COM library
legacy COM library which is built without Unicode (MBCS)
Windows 2008 dev server on which it all runs

Needed:
support web app users in different locales

Test:

1) I set the system locale on the server to Russian and tested Russian inputs.

.NET treats them as UTF16, passes on to COM as BSTR, COM converts it to char* using ConvertBSTRToString and current locale (russian), writes them to file, reads them to file, passes back to .NET and getting correct results.

2) I set the system locale back to US/English, add code to either ASP.NET app or the COM itself to set locale to Russian explicitly, the locale is set successfully (I query it and get Russian back), COM receives UTF-16 BSTR, uses ConvertBSTRToString to convert it to char* and gets question marks “???”!

Why?? What’s the difference between having system wide locale setting and calling setlocale() in the process? What is the point of setlocale then? Is ConvertBSTRToString using something other than current locale?

I have also tried doing

    System.Threading.Thread.CurrentThread.CurrentCulture = 
new System.Globalization.CultureInfo("ru-RU");

inside the ASP.NET caller of the COM object and tried doing

setlocale(LC_ALL, "Russian");

        SetThreadLocale(
MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_RUSSIAN_RUSSIA), SORT_DEFAULT));

along side the setlocale() inside the COM library; no effect.

I would really appreciate inputs on that!

  • 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-15T18:21:14+00:00Added an answer on May 15, 2026 at 6:21 pm

    It isn’t clear from the docs what ConvertBSTRToString() uses to determine the current locale. But you can be pretty sure that it is not the CRT locale as set by setlocale(). You almost certainly need to call SetThreadLocale().

    Use WideCharToMultiByte() to make it less of a guess.

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

Sidebar

Related Questions

simple question... Given I have an ASP.NET site, which uses a [custom] RoleProvider, Is
I'm writing specflow tests using Watin, for an Asp.Net MVC application which uses T4MVC.
I'm developing an ASP.NET MVC 3 application and it uses a complex model which
I have an Asp.net MVC application which uses html5 and jquery on the client
I have a web application built on ASP.NET MVC framework which requires a service
I'm working on a .Net application which uses Asp.net 3.5 and Lucene.Net I am
I have an ASP.NET web application which uses EF4. I have a page with
I have a legacy ASP.NET application in which there are some session/concurrency related issues
Given a large legacy project utilizing ASP.NET, javascript, css, etc, technologies, I was wondering
I have an ASP.NET MVC 2 application in which I am creating a custom

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.