Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Cameras
scaleDown command
black out solved
Aircraft Tutorial
Mathematical XYZ ?
Its done This vs That
Its done first week
recommendations for screen video captures?
3DExplorer "Oddity "
New Director
ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Texturing
Big Break Contest Videos
New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Plasma?
Looking for Inspiration
Weird EMail Q
It 's done first week ?
Cherry not cranberry
New game
Camera Animation Problem
Particle plugins?
 
C++ question

C++ question

2004-06-10       - By Alain Laferrière

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  


Thanks Jerry.


 __ __  

  From: owner-xsi@(protected) [mailto:owner-xsi@(protected)] On Behalf Of
Jerry Gamache
  Sent: Friday, June 11, 2004 3:40 AM
  To: XSI@(protected)
  Subject: RE: C++ question
 
 
  This seems like too much code. This can probably be simplified to:
 
 
    // string buffers
    char          charString[1024];
 
 
    // convert CString to char
    wcstombs( charString, myCString.GetWideString(), 1024 );
 
  And prevents a potential buffer overflow crash in swprintf if the string
happens to be longer than 1024 characters.
 
  If you really want the intermediate buffer, at least use _snwprintf instead of
swprintf.
  http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/buffer-overflow
.html
 

    -- --Original Message-- --
    From: owner-xsi@(protected) [mailto:owner-xsi@(protected)]On Behalf Of
Alain Laferrière
    Posted At: Thursday, June 10, 2004 12:31 PM
    Posted To: xsi
    Conversation: C++ question
    Subject: RE: C++ question
   
   
   
    Example ( myCString is the CString which gets converted to char string ) :
   
      // string buffers
      char          charString[1024];
      wchar_t     wcharString[1024];
   
      // convert CString to char
      swprintf( wcharString, L"%s", myCString.GetWideString() );
      wcstombs( charString, wcharString, 1024 );
   


 __ __  

      From: owner-xsi@(protected) [mailto:owner-xsi@(protected)] On Behalf Of
François Painchaud
      Sent: Thursday, June 10, 2004 11:53 PM
      To: XSI List
      Subject: Re: C++ question
     
     
      CString stores wide characters. Use CString method "const wchar_t*
GetWideString() const", then use "FILE* _wfopen( const wchar_t* filename, const
wchar_t* mode )" or a similar open function. You could also take a look at
function "int wctomb( char* mbchar, wchar_t wchar )".
     
      François
     
      -- ----- Message d'origine -- -----
Sujet:   C++ question  
Date:   Thu, 10 Jun 2004 15:58:11 +0200  
De:   "Helge Mathee" <helge.mathee@(protected)> <mailto:helge.mathee@(protected)>  
A:   <XSI@(protected)> <mailto:XSI@(protected)>  

      Maybe I am dumb.....
     
      how to convert a CString to a const char *?
     
      I need this to read files inside of a c++ operator...
     
      really weird... just doesn't work...
     
      thanks,
     
      helge


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859 (See http://iso-8859.ora-code.com)-1">
<META content="MSHTML 6.00.2737.800" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<DIV dir=ltr align=left><FONT face=Arial color=#000080
size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=413501919-10062004><FONT face=Arial
color=#000080 size=2>Thanks Jerry.</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
 <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
 <HR tabIndex=-1>
 <FONT face=Tahoma size=2><B>From:</B> owner-xsi@(protected)
 [mailto:owner-xsi@(protected)] <B>On Behalf Of </B>Jerry
 Gamache<BR><B>Sent:</B> Friday, June 11, 2004 3:40 AM<BR><B>To:</B>
 XSI@(protected)<BR><B>Subject:</B> RE: C++ question<BR></FONT><BR></DIV>
 <DIV></DIV>
 <DIV><SPAN class=093351318-10062004><FONT face="Comic Sans MS" color=#008080
 size=2>This seems like too much code. This can probably be simplified
 to:</FONT></SPAN></DIV>
 <DIV><SPAN class=093351318-10062004><FONT face="Comic Sans MS" color=#008080
 size=2></FONT></SPAN>&nbsp;</DIV>
 <DIV><SPAN class=093351318-10062004><FONT face="Comic Sans MS" color=#008080
 size=2>
 <DIV dir=ltr align=left><FONT face=Arial color=#000080 size=2>&nbsp;&nbsp; //
 string buffers <BR>&nbsp;&nbsp; char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN
 class=157212616-10062004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;charString</SPAN>[1024
];<BR></FONT></DIV>
 <DIV><FONT face=Arial color=#000080 size=2></FONT>&nbsp;</DIV>
 <DIV dir=ltr align=left><FONT face=Arial color=#000080 size=2>&nbsp;&nbsp; //
 convert CS<SPAN class=157212616-10062004>t</SPAN>ring to char<BR>&nbsp;&nbsp;
 wcstombs(&nbsp;charString, <SPAN class=157212616-10062004>my</SPAN><SPAN
 class=157212616-10062004>CString</SPAN>.GetWideString(), 1024
 );<BR></FONT></DIV></FONT></SPAN></DIV>
 <DIV><SPAN class=093351318-10062004><FONT face="Comic Sans MS" color=#008080
 size=2>And prevents a potential buffer overflow crash&nbsp;in swprintf if the
 string happens to be longer than 1024 characters.</FONT></SPAN></DIV>
 <DIV><SPAN class=093351318-10062004><FONT face="Comic Sans MS" color=#008080
 size=2></FONT></SPAN>&nbsp;</DIV>
 <DIV><SPAN class=093351318-10062004><FONT face="Comic Sans MS" color=#008080
 size=2>If you really want the intermediate buffer, at least use _snwprintf
 instead of swprintf.</FONT></SPAN></DIV>
 <DIV><SPAN class=093351318-10062004><FONT face="Comic Sans MS" color=#008080
 size=2><A
 href="http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/buffer
-overflow.html">http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO
/buffer-overflow.html</A></FONT></SPAN></DIV>
 <DIV><SPAN class=093351318-10062004><FONT face="Comic Sans MS" color=#008080
 size=2></FONT></SPAN>&nbsp;</DIV>
 <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
   <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
   size=2>-- --Original Message-- --<BR><B>From:</B> owner-xsi@(protected)
   [mailto:owner-xsi@(protected)]<B>On Behalf Of </B>Alain
   Laferrière<BR><B>Posted At:</B> Thursday, June 10, 2004 12:31
   PM<BR><B>Posted To:</B> xsi<BR><B>Conversation:</B> C++
   question<BR><B>Subject:</B> RE: C++ question<BR><BR></FONT></DIV>
   <DIV dir=ltr align=left><FONT face=Arial color=#000080
   size=2></FONT>&nbsp;</DIV>
   <DIV dir=ltr align=left><FONT face=Arial color=#000080 size=2><SPAN
   class=157212616-10062004>Example ( <SPAN
   class=157212616-10062004>my</SPAN><SPAN class=157212616-10062004>CString is
   the CString which gets converted to char string )
   :</SPAN></SPAN></FONT></DIV>
   <DIV dir=ltr align=left><FONT face=Arial color=#000080 size=2><SPAN
   class=157212616-10062004></SPAN></FONT><FONT face=Arial color=#000080
   size=2><SPAN class=157212616-10062004></SPAN></FONT><FONT face=Arial
   color=#000080 size=2><SPAN class=157212616-10062004></SPAN></FONT><FONT
   face=Arial color=#000080 size=2></FONT>&nbsp;</DIV>
   <DIV dir=ltr align=left><FONT face=Arial color=#000080 size=2>&nbsp;&nbsp;
   // string buffers <BR>&nbsp;&nbsp; char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN
   class=157212616-10062004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;charString</SPAN>
[1024];<BR><SPAN
   class=157212616-10062004>&nbsp;&nbsp;&nbsp;</SPAN>wchar_t&nbsp;<SPAN
   class=157212616-10062004>&nbsp;&nbsp;&nbsp;
   wcharString</SPAN>[1024];</FONT></DIV>
   <DIV><FONT face=Arial color=#000080 size=2></FONT>&nbsp;</DIV>
   <DIV dir=ltr align=left><FONT face=Arial color=#000080 size=2>&nbsp;&nbsp;
   // convert CS<SPAN class=157212616-10062004>t</SPAN>ring to
   char<BR>&nbsp;&nbsp; swprintf(&nbsp;<SPAN
   class=157212616-10062004>wcharString</SPAN>, L"%s",&nbsp;<SPAN
   class=157212616-10062004>my</SPAN><SPAN
   class=157212616-10062004>CString</SPAN>.GetWideString() );<BR>&nbsp;&nbsp;
   wcstombs(&nbsp;charString, wcharString, 1024 );<BR></FONT></DIV><BR>
   <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
     <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
     <HR tabIndex=-1>
     <FONT face=Tahoma size=2><B>From:</B> owner-xsi@(protected)
     [mailto:owner-xsi@(protected)] <B>On Behalf Of </B>François
     Painchaud<BR><B>Sent:</B> Thursday, June 10, 2004 11:53 PM<BR><B>To:</B>
     XSI List<BR><B>Subject:</B> Re: C++ question<BR></FONT><BR></DIV>
     <DIV></DIV>CString stores wide characters. Use CString method "const
     wchar_t* GetWideString() const", then use "FILE* _wfopen( const wchar_t*
     filename, const wchar_t* mode )" or a similar open function. You could
     also take a look at function "int wctomb( char* mbchar, wchar_t wchar
     )".<BR><BR>François<BR>&nbsp;<BR>-- ----- Message d'origine -- -----
     <TABLE cellSpacing=0 cellPadding=0 border=0>
       <TBODY>
       <TR>
         <TH vAlign=baseline noWrap align=right>Sujet: </TH>
         <TD>C++ question</TD></TR>
       <TR>
         <TH vAlign=baseline noWrap align=right>Date: </TH>
         <TD>Thu, 10 Jun 2004 15:58:11 +0200</TD></TR>
       <TR>
         <TH vAlign=baseline noWrap align=right>De: </TH>
         <TD>"Helge Mathee" <A class=moz-txt-link-rfc2396E
           href="mailto:helge.mathee@(protected)">&lt;helge.mathee@(protected)&gt;</A>
</TD></TR>
       <TR>
         <TH vAlign=baseline noWrap align=right>A: </TH>
         <TD><A class=moz-txt-link-rfc2396E
           href="mailto:XSI@(protected)">&lt;XSI@(protected)&gt;</A></TD><
/TR></TBODY></TABLE><BR>
     <META content="MSHTML 6.00.2737.800" name=GENERATOR>
     <STYLE></STYLE>

     <DIV><FONT face=Arial size=2>Maybe I am dumb.....</FONT></DIV>
     <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
     <DIV><FONT face=Arial size=2>how to convert a CString to a const char
     *?</FONT></DIV>
     <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
     <DIV><FONT face=Arial size=2>I need this to read files inside of a c++
     operator...</FONT></DIV>
     <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
     <DIV><FONT face=Arial size=2>really weird... just doesn't
     work...</FONT></DIV>
     <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
     <DIV><FONT face=Arial size=2>thanks,</FONT></DIV>
     <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
     <DIV><FONT face=Arial
size=2>helge</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>