Click here to Skip to main content
15,908,841 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralInstall Shield Pin
mohdshiraz18-Mar-04 4:13
mohdshiraz18-Mar-04 4:13 
GeneralRe: Install Shield Pin
Heath Stewart18-Mar-04 4:46
protectorHeath Stewart18-Mar-04 4:46 
Generalctreectrl and its normal image list Pin
Anonymous18-Mar-04 4:07
Anonymous18-Mar-04 4:07 
GeneralRe: ctreectrl and its normal image list Pin
Yogurt18-Mar-04 6:06
Yogurt18-Mar-04 6:06 
GeneralDrive in explorer Pin
Peter Liddle18-Mar-04 3:56
Peter Liddle18-Mar-04 3:56 
GeneralRe: Drive in explorer Pin
Peter Liddle18-Mar-04 4:11
Peter Liddle18-Mar-04 4:11 
GeneralRe: Drive in explorer Pin
Michael Dunn18-Mar-04 5:03
sitebuilderMichael Dunn18-Mar-04 5:03 
GeneralAnsi to Unicode string using basic_string Pin
Jim Crafton18-Mar-04 3:23
Jim Crafton18-Mar-04 3:23 
I have an ansi c string, and I'd like to convert it to Unicode and stuff this into a std::basic_string<wchar_t>.

So, I thought I could do the following :
void transformAnsiToUnicode( const char* str, int stringLength, std::basic_string<wchar_t>& newStr )

  int size = MultiByteToWideChar( CP_ACP, 0, str, stringLength, NULL, 0 );

  newStr.resize( size );
  int err = MultiByteToWideChar( CP_ACP, 0, str, stringLength, (wchar_t*)newStr.begin(), size );
  if ( 0 == err ) {
    err = GetLastError();
  }


Now on VC6 this works perfectly (with either the default STL or with STL Port). On VC7 it bitches about
(wchar_t*)newStr.begin()


Is there away around this?
Is this even *legal* to do? Or do I have to allocate a new wchar_t buffer, use that with MultiByteToWideChar(), and then assign to the newStr variable, and then delete it?

Thanks




¡El diablo está en mis pantalones! ¡Mire, mire!

Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!

SELECT * FROM User WHERE Clue > 0
0 rows returned

GeneralRe: Ansi to Unicode string using basic_string Pin
Prakash Nadar18-Mar-04 4:43
Prakash Nadar18-Mar-04 4:43 
GeneralRe: Ansi to Unicode string using basic_string Pin
J. Eric Vaughan18-Mar-04 5:04
J. Eric Vaughan18-Mar-04 5:04 
GeneralRe: Ansi to Unicode string using basic_string Pin
Michael Dunn18-Mar-04 5:05
sitebuilderMichael Dunn18-Mar-04 5:05 
GeneralRe: Ansi to Unicode string using basic_string Pin
Jim Crafton18-Mar-04 5:18
Jim Crafton18-Mar-04 5:18 
GeneralSecondary display monitor dimensions win32 Pin
Anonymous18-Mar-04 2:59
Anonymous18-Mar-04 2:59 
GeneralRe: Secondary display monitor dimensions win32 Pin
David Crow18-Mar-04 3:06
David Crow18-Mar-04 3:06 
GeneralSharing child windows Pin
Jason Henderson18-Mar-04 2:57
Jason Henderson18-Mar-04 2:57 
GeneralRe: Sharing child windows Pin
Prakash Nadar18-Mar-04 4:26
Prakash Nadar18-Mar-04 4:26 
GeneralRe: Sharing child windows Pin
Jason Henderson18-Mar-04 9:11
Jason Henderson18-Mar-04 9:11 
GeneralRe: Sharing child windows Pin
Prakash Nadar18-Mar-04 14:27
Prakash Nadar18-Mar-04 14:27 
GeneralHooking Dialup Network calls Pin
Harrold18-Mar-04 2:48
Harrold18-Mar-04 2:48 
GeneralGet memory info Pin
Anonymous18-Mar-04 2:24
Anonymous18-Mar-04 2:24 
GeneralRe: Get memory info Pin
David Crow18-Mar-04 2:40
David Crow18-Mar-04 2:40 
GeneralRe: Get memory info Pin
John M. Drescher18-Mar-04 3:20
John M. Drescher18-Mar-04 3:20 
GeneralRe: Get memory info Pin
Alexander M.,18-Mar-04 9:29
Alexander M.,18-Mar-04 9:29 
Generalreverseengingeering!!!! Pin
gelcoman18-Mar-04 2:18
gelcoman18-Mar-04 2:18 
GeneralRe: reverseengingeering!!!! Pin
Steve S18-Mar-04 2:41
Steve S18-Mar-04 2:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.