• Advertisement

C++ Getting unicode from an ini file

Recommended Posts

Hi, this is my first post here and i hope to get an answer :)
My question is i am reading the section names from an file Unfortunately these section name contains unicode chars so when i read them i just get ???? 
here's my code ...

TCHAR buffer[4096];
int Lsize = sizeof(buffer),length;
TCHAR *Get = buffer;
while (*Get){
length = strlen(Get);
Get += length;


Share this post

Link to post
Share on other sites

Okay guys the problem was that the ini file was UTF-8 and not unicode hhhhhhhh 
Anway i wanted to ask another question ...
Since the Get and buffer are not char and TCHAR 
So when i use MessageBox::Show(Get);
It will give me error so i have tried this :
String ^GetResult = gcnew String(Get);
This one works but i don't know how this line works String ^GetResult = gcnew String(Get);
Can you please explain it ?

Share this post

Link to post
Share on other sites

Ouch, you're using managed C++. That's one ugly beast and usually only used for interfacing :)

It's combining C++ with .NET, and therefore has a few warts to transfer data between runtimes. Any reason why you're using this?


^ is a managed reference (somewhat like a * pointer in C/C++).
gcnew is the new of C++, creating a managed reference.
String( Get) is the constructor of the .NET String class which lets you pass in a char array.

So all you do in that line is creating a new managed instance of String, initialised with your char array.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement