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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:39:38+00:00 2026-05-26T11:39:38+00:00

Good Day, I’ve been writing a simple program using the Windows API, it’s written

  • 0

Good Day,
I’ve been writing a simple program using the Windows API, it’s written in C++/CLI.
The problem I’ve encountered is, I’m loading a library (.dll) and then calling its functions. one of the functions returns char*. So I add the returned value to my textbox

output->Text = System::Runtime::InteropServices::Marshal::PtrToStringAnsi
                   (IntPtr(Function()));

Now, as you can see this is encoded in ANSI, the char* returned is, I presume, also ANSI (or Windows-1252, w/e you guys call it :>). The original data, which the function in LIBRARY gets is encoded in UTF-8, variable-length byte field, terminated by 0x00. There are a lot of non-Latin characters in my program, so this is troubling. I’ve also tried this

USES_CONVERSION;
wchar_t* pUnicodeString = 0;
pUnicodeString = A2W( Function());

output->Text = System::Runtime::InteropServices::Marshal::PtrToStringUni
                   (IntPtr(pUnicodeString));

using atlconv.h. It still prints malformed/wrong characters. So my question would be, can I convert it to something like UTF-8 so I would be able to see correct output, or does the char* loose the necessary information required to do so? Maybe changing the .dll source code would help, but it’s quite old and written in C, so i don’t want to mess with it :/
I hope the information I provided was sufficient, if you need anything more, just ask.

  • 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-26T11:39:38+00:00Added an answer on May 26, 2026 at 11:39 am

    As I know there is no standard way to handle UTF-8. Try to google appropriate converters, e.g. http://www.nuclex.org/articles/cxx/10-marshaling-strings-in-cxx-cli , Convert from C++/CLI pointer to native C++ pointer .

    Also, your second code snippet doesn’t use pUnicodeString, it doesn’t look right.

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

Sidebar

Related Questions

Good day everyone. This problem was part of another one which it as been
Good day! I encountered the following error upon running my JSP program. java.lang.IllegalStateException: PWC3991:
Good day, I'm having a problem with asp.net 2.0 viewstate. Basically, I want to
Good day everyone, I am building a page in ASP.NET, and using Master Pages
Good day, I am using CacheFilter to filter a certain path to my server
Good day! I am using Xcode 3.1.4 and iPhone SDK 2.2.1. I am creating
Good day, I've just started teaching myself VB.net. I'm trying to create a simple
Good day, I've got a simple CSS question. I'm trying to change a table
Good day, I have this problem with Html.DropDownListFor which I can't seem to work
Good day. I am trying to fetch an asp.net label control's text value using

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.