|
Prev: KB831875
Next: speedy get folder size
From: Wallace on 26 Apr 2006 09:09 Hai all, can anyone tell me how to convert const BYTE *str into a CString str without data loss? Please help... urgent... Thanx in advance.... Looking forward for the response....
From: David Wilkinson on 26 Apr 2006 10:15 Wallace wrote: > Hai all, > > can anyone tell me how to convert const BYTE *str into a CString str > without data loss? > > Please help... urgent... > > Thanx in advance.... Looking forward for the response.... > Wallace: Try to use a meaningful title for your posts. BYTE is unsigned char. The answer to this question should, IMO, depend on whether you are in an ANSI or Unicode build. In ANSI build, I think you should (a) cast to const char* (aka LPCSTR), and (b) use CString constructor. In Unicode build you should (a) cast to const char*, (b) convert to wide string using MultiByteToWideChar() or one of the A2W conversion routines, and (c) use the CString constructor. However, as it happens, CString has a constructor that takes a const unsigned char and that works in either build (a bad feature, IMO), so you can use that if you want to do the conversion using the local code page. David Wilkinson
From: mzdude on 26 Apr 2006 10:28 Wallace wrote: > Hai all, > > can anyone tell me how to convert const BYTE *str into a CString str > without data loss? > > Please help... urgent... > > Thanx in advance.... Looking forward for the response.... This sounds like a loaded question, but I'll bite (pun intended). Assumming your working in the MCBS world and no embedded nulls in the BYTE *str then the following should work fine. const BYTE buffer[] = "This is my string"; const BYTE *str = &buffer[0]; CString myString( str ); // no loss of data CString two; two = str; // makes a copy
|
Pages: 1 Prev: KB831875 Next: speedy get folder size |