Click here to Skip to main content
15,887,135 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Detect Internet Explorer 7 Pin
bob1697221-Apr-09 8:18
bob1697221-Apr-09 8:18 
QuestionWho can find my import file ! mingw32 problem!!! Pin
zarelaky21-Apr-09 5:13
zarelaky21-Apr-09 5:13 
AnswerRe: Who can find my import file ! mingw32 problem!!! Pin
Stuart Dootson21-Apr-09 8:34
professionalStuart Dootson21-Apr-09 8:34 
GeneralRe: Who can find my import file ! mingw32 problem!!! Pin
zarelaky22-Apr-09 1:41
zarelaky22-Apr-09 1:41 
GeneralRe: Who can find my import file ! mingw32 problem!!! Pin
Stuart Dootson22-Apr-09 2:04
professionalStuart Dootson22-Apr-09 2:04 
GeneralRe: Who can find my import file ! mingw32 problem!!! Pin
zarelaky22-Apr-09 4:06
zarelaky22-Apr-09 4:06 
QuestionWriting a Unicode File using wofstream [modified] Pin
A&Ms21-Apr-09 4:33
A&Ms21-Apr-09 4:33 
AnswerRe: Writing a Unicode File using wofstream Pin
Stuart Dootson21-Apr-09 8:33
professionalStuart Dootson21-Apr-09 8:33 
Wide file streams in C++ actually (by default) write single byte characters to files (see this Google groups posting[^] for details). The characters you've provided aren't convertible into your default codepage, so it's game over!

I believe that if you imbue[^] your file stream with a locale[^] that has a codecvt facet[^] that converts to some Unicode encoding, then you'll get proper wide character files.

In fact, this code (which uses the appropriate codecvt facet from this CP article[^]) will do just that!:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

#include <locale>

using std::codecvt ; 
typedef codecvt < wchar_t , char , mbstate_t > NullCodecvtBase ;

class NullCodecvt
   : public NullCodecvtBase
{

public:
   typedef wchar_t _E ;
   typedef char _To ;
   typedef mbstate_t _St ;

   explicit NullCodecvt( size_t _R=0 ) : NullCodecvtBase(_R) { }

protected:
   virtual result do_in( _St& _State ,
      const _To* _F1 , const _To* _L1 , const _To*& _Mid1 ,
      _E* F2 , _E* _L2 , _E*& _Mid2
      ) const
   {
      return noconv ;
   }
   virtual result do_out( _St& _State ,
      const _E* _F1 , const _E* _L1 , const _E*& _Mid1 ,
      _To* F2, _E* _L2 , _To*& _Mid2
      ) const
   {
      return noconv ;
   }
   virtual result do_unshift( _St& _State , 
      _To* _F2 , _To* _L2 , _To*& _Mid2 ) const
   {
      return noconv ;
   }
   virtual int do_length( _St& _State , const _To* _F1 , 
      const _To* _L1 , size_t _N2 ) const _THROW0()
   {
      return (_N2 < (size_t)(_L1 - _F1)) ? _N2 : _L1 - _F1 ;
   }
   virtual bool do_always_noconv() const _THROW0()
   {
      return true ;
   }
   virtual int do_max_length() const _THROW0()
   {
      return 2 ;
   }
   virtual int do_encoding() const _THROW0()
   {
      return 2 ;
   }
} ;

int _tmain(int argc, _TCHAR* argv[])
{
   wofstream of("./a.txt",std::ios::out | std::ios::binary);
   std::locale l( std::locale(), new NullCodecvt);
   of.imbue( l ) ;
   of << "Hello";
   of.close();
   return 0;
}


Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

AnswerRe: Writing a Unicode File using wofstream Pin
A&Ms21-Apr-09 10:43
A&Ms21-Apr-09 10:43 
GeneralRe: Writing a Unicode File using wofstream Pin
Stuart Dootson21-Apr-09 10:51
professionalStuart Dootson21-Apr-09 10:51 
GeneralRe: Writing a Unicode File using wofstream Pin
A&Ms21-Apr-09 22:17
A&Ms21-Apr-09 22:17 
GeneralRe: Writing a Unicode File using wofstream Pin
Stuart Dootson21-Apr-09 22:28
professionalStuart Dootson21-Apr-09 22:28 
GeneralRe: Writing a Unicode File using wofstream Pin
A&Ms22-Apr-09 6:53
A&Ms22-Apr-09 6:53 
QuestionComparison of (int)DWORD Pin
Mikey_H21-Apr-09 4:27
Mikey_H21-Apr-09 4:27 
AnswerRe: Comparison of (int)DWORD Pin
Cedric Moonen21-Apr-09 4:32
Cedric Moonen21-Apr-09 4:32 
GeneralRe: Comparison of (int)DWORD Pin
Mikey_H21-Apr-09 4:42
Mikey_H21-Apr-09 4:42 
GeneralRe: Comparison of (int)DWORD Pin
Cedric Moonen21-Apr-09 4:46
Cedric Moonen21-Apr-09 4:46 
GeneralRe: Comparison of (int)DWORD [modified] Pin
Mikey_H21-Apr-09 5:07
Mikey_H21-Apr-09 5:07 
GeneralRe: Comparison of (int)DWORD Pin
Cedric Moonen21-Apr-09 7:20
Cedric Moonen21-Apr-09 7:20 
GeneralRe: Comparison of (int)DWORD Pin
Mikey_H21-Apr-09 7:24
Mikey_H21-Apr-09 7:24 
GeneralRe: Comparison of (int)DWORD Pin
Cedric Moonen21-Apr-09 8:22
Cedric Moonen21-Apr-09 8:22 
QuestionRe: Comparison of (int)DWORD Pin
David Crow21-Apr-09 7:56
David Crow21-Apr-09 7:56 
AnswerRe: Comparison of (int)DWORD Pin
Perry Holman21-Apr-09 7:13
Perry Holman21-Apr-09 7:13 
QuestionHow can i Discovery all user-defined process name from a unknow DLL Pin
SNArruda21-Apr-09 4:25
SNArruda21-Apr-09 4:25 
AnswerRe: How can i Discovery all user-defined process name from a unknow DLL Pin
Cedric Moonen21-Apr-09 4:51
Cedric Moonen21-Apr-09 4:51 

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.