Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ansistring to widestring conversion.

Status
Not open for further replies.

Tremorblue

Programmer
Apr 30, 2004
56
0
0
GB
I have a couple of functions that write ansistring to a file or to an internal buffer.
I have been trying to figure out how to convert them to use widestring , can anyone help, Im stuck!

I still need the internal buffer to stay as char.

Thankyou.


void __fastcall TFormMain::WriteDataToFile(int iFileHandle,AnsiString aData)
{
MemoryOrDisk(iFileHandle,aData.c_str(),aData.Length());
}

void __fastcall TFormMain::MemoryOrDisk(int iFileHandle,char *cData,int iLength)
{
if(iFileHandle>0)
{
FileWrite(iFileHandle,cData,iLength);
}else
{
strncpy(&c_InternalBuffer[l_InternalBufferPosition],cData,iLength);
l_InternalBufferPosition+=iLength;
}
}
 
I don't know if this thread is what you are looking for but it might be a start. They start out with a discussion of characters and then move into widestrings.


James P. Cottingham
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
I'am not sure if I understand your problem well.

But AnsiString has an function dat convert itself to a widestring:

ansiStr.WideChar(dest,int);

ansiStr is an AnsiString.
dest is a wchar_t*

And there are more functions like:
WideString(ansiStr.c_str());

There exist also
<stddef.h>
wchar_t
typedef i-type wchar_t; [keyword in C++]
The type is the integer type i-type of a wide-character constant, such as L'X'. You declare an object of type wchar_t to hold a wide character.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top