Click here to Skip to main content
16,010,876 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: help with some date/time input pls Pin
David Crow29-Jun-05 16:58
David Crow29-Jun-05 16:58 
GeneralRe: help with some date/time input pls Pin
neodeaths2-Jul-05 9:40
neodeaths2-Jul-05 9:40 
GeneralRe: help with some date/time input pls Pin
David Crow2-Jul-05 12:07
David Crow2-Jul-05 12:07 
GeneralRe: help with some date/time input pls Pin
neodeaths2-Jul-05 17:50
neodeaths2-Jul-05 17:50 
GeneralRe: help with some date/time input pls Pin
David Crow4-Jul-05 11:42
David Crow4-Jul-05 11:42 
GeneralNumber of bytes in a mbcs string Pin
Chintoo72329-Jun-05 3:28
Chintoo72329-Jun-05 3:28 
GeneralRe: Number of bytes in a mbcs string Pin
RChin29-Jun-05 4:40
RChin29-Jun-05 4:40 
GeneralRe: Number of bytes in a mbcs string Pin
Jose Lamas Rios29-Jun-05 4:41
Jose Lamas Rios29-Jun-05 4:41 
If you know you have a multibyte string, you can simply use strlen() to obtain the number of bytes.

void SomeFunction(LPSTR pString)
{
	int nChars = _mbslen(pString);
	int nBytes = strlen(pString);
	[...]
}


If you are using the TCHAR macros you can do it like this:

void SomFunction(LPTSTR pString)
{
	int nChars = _tcsclen(pString);
	int nBytes = _tcslen(pString) * sizeof(TCHAR);
}


Note _tcslen is different than _tcsclen.

If _UNICODE is not defined, _tcslen resolves to strlen, and sizeof(TCHAR)==1.
If _UNICODE is defined, _tcslen resolves to wcslen, and sizeof(TCHAR)==2.

So, _tcslen(pString) * sizeof(TCHAR) will give you the number of bytes in any case.

Hope that helps,


--
jlr
http://jlamas.blogspot.com/[^]
GeneralRe: Number of bytes in a mbcs string Pin
Chintoo72329-Jun-05 4:54
Chintoo72329-Jun-05 4:54 
GeneralRe: Number of bytes in a mbcs string Pin
Jose Lamas Rios29-Jun-05 5:04
Jose Lamas Rios29-Jun-05 5:04 
GeneralRe: Number of bytes in a mbcs string Pin
Andrew Kirillov29-Jun-05 4:58
Andrew Kirillov29-Jun-05 4:58 
GeneralRe: Number of bytes in a mbcs string Pin
Jose Lamas Rios29-Jun-05 5:07
Jose Lamas Rios29-Jun-05 5:07 
Questionany limitations to VTable ??? Pin
Abhi Lahare29-Jun-05 3:24
Abhi Lahare29-Jun-05 3:24 
AnswerRe: any limitations to VTable ??? Pin
Chris Losinger29-Jun-05 3:33
professionalChris Losinger29-Jun-05 3:33 
GeneralRe: any limitations to VTable ??? Pin
Chintoo72329-Jun-05 3:41
Chintoo72329-Jun-05 3:41 
GeneralRe: any limitations to VTable ??? Pin
Chintoo72329-Jun-05 3:42
Chintoo72329-Jun-05 3:42 
GeneralRe: any limitations to VTable ??? Pin
Chris Losinger29-Jun-05 3:48
professionalChris Losinger29-Jun-05 3:48 
GeneralRe: any limitations to VTable ??? Pin
Chintoo72329-Jun-05 3:55
Chintoo72329-Jun-05 3:55 
GeneralRe: any limitations to VTable ??? Pin
Chintoo72329-Jun-05 3:56
Chintoo72329-Jun-05 3:56 
GeneralRe: any limitations to VTable ??? Pin
Chris Losinger29-Jun-05 4:03
professionalChris Losinger29-Jun-05 4:03 
GeneralRe: any limitations to VTable ??? Pin
Chintoo72329-Jun-05 4:18
Chintoo72329-Jun-05 4:18 
GeneralRe: any limitations to VTable ??? Pin
Chris Losinger29-Jun-05 4:23
professionalChris Losinger29-Jun-05 4:23 
GeneralRe: any limitations to VTable ??? Pin
Chintoo72329-Jun-05 4:34
Chintoo72329-Jun-05 4:34 
Generalcan't compile my codes...pls help Pin
Member 208234129-Jun-05 2:11
Member 208234129-Jun-05 2:11 
GeneralRe: can't compile my codes...pls help Pin
Cillieacc0rd5o429-Jun-05 2:14
Cillieacc0rd5o429-Jun-05 2:14 

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.