Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages
Started by Wayne Smith
Wed, 22 Aug 2007 17:01
Convert AnsiString to a wchar_t
Author: Wayne Smith
Date: Wed, 22 Aug 2007 17:01
Date: Wed, 22 Aug 2007 17:01
4 lines
1045 bytes
1045 bytes
Does anyone have an example of converting an AnsiString to a wchar_t? Thanks in advance, Wayne
Re: Convert AnsiString to a wchar_t
Author: Damon Chandler (TeamB)
Date: Wed, 22 Aug 2007 17:12
Date: Wed, 22 Aug 2007 17:12
20 lines
1280 bytes
1280 bytes
Hi Wayne, Have a look at the AnsiString::WideChar() method. You could also use the WideString class. Cheers, -- Damon Chandler (TeamB) C++Builder Developer's Journal http://bcbjournal.com http://bcbjournal.org Wayne Smith wrote: > Does anyone have an example of converting an AnsiString to a wchar_t? > > Thanks in advance, > Wayne > >
Re: Convert AnsiString to a wchar_t
Author: Wayne Smith
Date: Wed, 22 Aug 2007 17:18
Date: Wed, 22 Aug 2007 17:18
37 lines
1681 bytes
1681 bytes
Damon, I looked at the help, but it wasn't much help. I am including my AnsiString. How would you convert it to a wchar_t? AnsiString temp = "c:\\scanexam\\" + ebDlrNmbr->Text.Trim() + "_" + newnumber.Trim() + ".jpg"; Thanks again, Wayne "Damon Chandler (TeamB)" <editor@NOSPAM.bcbjournal.com> wrote in message news:46cc6e81$1@newsgroups.borland.com... > Hi Wayne, > > Have a look at the AnsiString::WideChar() method. You could also use the > WideString class. > > Cheers, > -- > Damon Chandler (TeamB) > C++Builder Developer's Journal > http://bcbjournal.com > http://bcbjournal.org > > > Wayne Smith wrote: >> Does anyone have an example of converting an AnsiString to a wchar_t? >> >> Thanks in advance, >> Wayne >>
Re: Convert AnsiString to a wchar_t
Author: Remy Lebeau (TeamB)
Date: Wed, 22 Aug 2007 19:50
Date: Wed, 22 Aug 2007 19:50
35 lines
1954 bytes
1954 bytes
"Wayne Smith" <wsmith@epgins.com> wrote in message
news:46cc7064$1@newsgroups.borland.com...
> I am including my AnsiString. How would you convert it to a wchar_t?
You can use the WideString class, like Damon suggested, ie:
WideString temp = "c:\\scanexam\\" + ebDlrNmbr->Text.Trim() + "_" +
newnumber.Trim() + ".jpg";
Or:
AnsiString asTemp = "c:\\scanexam\\" + ebDlrNmbr->Text.Trim() + "_" +
newnumber.Trim() + ".jpg";
WideString wTemp = astemp;
WideString is a wrapper for a BSTR, which is based on wchar_t. As such, it
can be used anywhere a wchar_t* is expected.
If you don't want to use the WideString class, then you need to allocate
your own wchar_t buffer that is large enough to convert the AnsiString into,
ie:
AnsiString asTemp = "c:\\scanexam\\" + ebDlrNmbr->Text.Trim() + "_" +
newnumber.Trim() + ".jpg";
int iSize = asTemp.WideCharBufSize();
wchar_t *wTemp = new wchar_t[iSize];
asTemp.WideChar(wTemp, iSize);
// use wTemp as needed...
delete[] wTemp;
Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads