Click here to Skip to main content
15,899,475 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem to launch chm file in Visual C++ Pin
Tim Deveaux17-Dec-00 9:32
Tim Deveaux17-Dec-00 9:32 
GeneralPlease Help! - CPropertySheetEx in ATL COM Server Pin
Girish Betadpur14-Dec-00 20:40
Girish Betadpur14-Dec-00 20:40 
GeneralRe: Please Help! - CPropertySheetEx in ATL COM Server Pin
Michael Dunn15-Dec-00 6:10
sitebuilderMichael Dunn15-Dec-00 6:10 
Generalconversion from UNICODE to unsigned char Pin
14-Dec-00 19:43
suss14-Dec-00 19:43 
GeneralRe: conversion from UNICODE to unsigned char Pin
Jonathan Gilligan14-Dec-00 20:08
Jonathan Gilligan14-Dec-00 20:08 
GeneralRe: conversion from UNICODE to unsigned char Pin
Michael Dunn15-Dec-00 6:12
sitebuilderMichael Dunn15-Dec-00 6:12 
GeneralRe: conversion from UNICODE to unsigned char Pin
15-Dec-00 21:09
suss15-Dec-00 21:09 
GeneralRe: conversion from UNICODE to unsigned char Pin
Julien21-Dec-00 12:35
Julien21-Dec-00 12:35 
Hi Anil,

The funcitons mbstowcs and wcstombs are documented in MSDN and do exactly
the conversion you are asking about. However when you are implementing
a system that has both chars and wchars you find yourself doing conversions
all over the place just so you can do things like strcmp.
[And instancinting tempory string objects is even worse]

So try the follow code segment to give you the string functions you want.
You will be able to use the function safe_strncpy to copy from either wchar
to char, char to wchar, char to char and wchar to wchar!
I have found this particularly useful for gradually changing chars to wchars
in a project as the other version of the function automatically steps in.

One day I'll write it up to post to CodeProject.

Jules

--- Code begins here, sorry if the format gets broken along the way ----

** Change of plan - the message was too long!

The function header is

template<class s1,="" class="" s2="">
int safe_strncpy(S1* szDest, const S2* szSrc, unsigned int iLen);
template<class s1,="" class="" s2="">
int safe_strncmp(const S1* szA, const S2* szB, int iLen=-1);
template<class s1="">
int safe_strlen(const S1* szString);
template<class s1,="" class="" s2="">
const S1* safe_strstr(const S1* sz1, const S2* sz2);

and you just use either char or wchar to do the work.

Tell me if you are interested and I'll email the FULL template to you.
GeneralVisual C++ 6.0 BIG problem!!! Pin
Yong Haur TAY14-Dec-00 16:40
Yong Haur TAY14-Dec-00 16:40 
GeneralRe: Visual C++ 6.0 BIG problem!!! Pin
Matt Philmon14-Dec-00 18:08
Matt Philmon14-Dec-00 18:08 
GeneralRe: Visual C++ 6.0 BIG problem!!! Pin
Yong Haur TAY15-Dec-00 14:50
Yong Haur TAY15-Dec-00 14:50 
GeneralRe: Visual C++ 6.0 BIG problem!!! Pin
Matt Philmon14-Dec-00 18:12
Matt Philmon14-Dec-00 18:12 
GeneralRe: Visual C++ 6.0 BIG problem!!! Pin
Yong Haur TAY15-Dec-00 14:59
Yong Haur TAY15-Dec-00 14:59 
GeneralRe: Visual C++ 6.0 BIG problem!!! Pin
Yong Haur TAY18-Dec-00 1:36
Yong Haur TAY18-Dec-00 1:36 
GeneralSolved!!! Visual C++ 6.0 BIG problem!!! Pin
Yong Haur TAY18-Dec-00 16:40
Yong Haur TAY18-Dec-00 16:40 
GeneralRe: Visual C++ 6.0 BIG problem!!! Pin
Matt Philmon15-Dec-00 16:23
Matt Philmon15-Dec-00 16:23 
GeneralCrash on Project Conversions Pin
Ron Ginsberg14-Dec-00 15:08
Ron Ginsberg14-Dec-00 15:08 
General:confused: PLEASE help me with a simple DOS C++ programming problem Pin
14-Dec-00 12:30
suss14-Dec-00 12:30 
GeneralRe: :confused: PLEASE help me with a simple DOS C++ programming problem Pin
Erik Funkenbusch14-Dec-00 12:43
Erik Funkenbusch14-Dec-00 12:43 
GeneralRe: :confused: PLEASE help me with a simple DOS C++ programming problem Pin
14-Dec-00 12:54
suss14-Dec-00 12:54 
GeneralRe: :confused: PLEASE help me with a simple DOS C++ programming problem Pin
Erik Funkenbusch14-Dec-00 13:46
Erik Funkenbusch14-Dec-00 13:46 
GeneralRe: :confused: PLEASE help me with a simple DOS C++ programming problem Pin
14-Dec-00 14:19
suss14-Dec-00 14:19 
GeneralRe: :confused: PLEASE help me with a simple DOS C++ programming problem Pin
14-Dec-00 15:01
suss14-Dec-00 15:01 
GeneralRe: :confused: PLEASE help me with a simple DOS C++ programming problem Pin
Erik Funkenbusch15-Dec-00 11:50
Erik Funkenbusch15-Dec-00 11:50 
GeneralDirectX screensaver Pin
Amit Dey14-Dec-00 5:23
Amit Dey14-Dec-00 5:23 

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.