Click here to Skip to main content
15,903,030 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Using microsoft STL and STLport in same project Pin
Vishal Kumar Soni1-Jul-09 6:02
Vishal Kumar Soni1-Jul-09 6:02 
GeneralRe: Using microsoft STL and STLport in same project Pin
AVIJIT NANDI7-Feb-10 19:53
AVIJIT NANDI7-Feb-10 19:53 
QuestionRe: Using microsoft STL and STLport in same project Pin
AVIJIT NANDI7-Feb-10 20:04
AVIJIT NANDI7-Feb-10 20:04 
AnswerRe: Using microsoft STL and STLport in same project Pin
Vishal Kumar Soni9-Feb-10 17:46
Vishal Kumar Soni9-Feb-10 17:46 
GeneralRe: Using microsoft STL and STLport in same project Pin
AVIJIT NANDI9-Feb-10 18:45
AVIJIT NANDI9-Feb-10 18:45 
GeneralRe: Using microsoft STL and STLport in same project Pin
sbansal714-Sep-11 14:38
sbansal714-Sep-11 14:38 
QuestionMy codecvt (a.k.a. facet) never gets called. Pin
John R. Shaw27-Jun-09 9:35
John R. Shaw27-Jun-09 9:35 
AnswerRe: My codecvt (a.k.a. facet) never gets called. Pin
Stuart Dootson28-Jun-09 23:37
professionalStuart Dootson28-Jun-09 23:37 
From what I can tell, the C++ stream system presumes that files are sequences of bytes, not characters - even when you use wide streams - the 'wide' part of wide stream (AFAICT) indicates how the stream object interacts with C++, not the underlying file or whatever. Thus, your codecvt facet has to take in characters.

By changing the declaration of your codecvt facet to that shown below, I was able to get breakpoints in the replacement facet being set.

class utf16_codecvt : public std::codecvt<char16_t, char, std::mbstate_t>
{
   typedef std::codecvt<char16_t, char, std::mbstate_t> Base;
   typedef char16_t ElemT;
   typedef char ByteT;
   virtual result __CLR_OR_THIS_CALL do_in(std::mbstate_t& s,
      const ByteT *_First1, const ByteT *_Last1, const ByteT *& _Mid1,
      ElemT*_First2, ElemT* _Last2, ElemT *& _Mid2) const
   {	// convert bytes [_First1, _Last1) to [_First2, _Last)
      return Base::do_in(s, _First1, _Last1, _Mid1, _First2, _Last2, _Mid2);
   }

   virtual result __CLR_OR_THIS_CALL do_out(std::mbstate_t& s,
      const ElemT*_First1, const ElemT*_Last1, const ElemT*& _Mid1,
      ByteT*_First2, ByteT*_Last2, ByteT*& _Mid2) const
   {	// convert [_First1, _Last1) to bytes [_First2, _Last)
      return Base::do_out(s, _First1, _Last1, _Mid1, _First2, _Last2, _Mid2);
   }

   virtual result __CLR_OR_THIS_CALL do_unshift(std::mbstate_t& s,
      ByteT*_First2, ByteT*_Last2, ByteT*&_Mid2) const
   {	// generate bytes to return to default shift state
      return Base::do_unshift(s, _First2, _Last2, _Mid2);
   }

   virtual int __CLR_OR_THIS_CALL do_length(const std::mbstate_t& s, const ByteT*_First1,
      const ByteT*_Last1, size_t _Count) const
   {	// return min(_Count, converted length of bytes [_First1, _Last1))
      return Base::do_length(s, _First1, _Last1, _Count);
   }
};


So, your replacement facet will have to know it needs two bytes read for every character (and vice versa, obviously). The best reference for that sort of information is probably Standard C++ IOStreams and Locales by Angelika Langer and Klaus Kreft[^] - but even then, locales and facets are heavy going in C++ Frown | :-(

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

GeneralRe: My codecvt (a.k.a. facet) never gets called. Pin
John R. Shaw29-Jun-09 2:43
John R. Shaw29-Jun-09 2:43 
GeneralRe: My codecvt (a.k.a. facet) never gets called. Pin
Stuart Dootson29-Jun-09 3:16
professionalStuart Dootson29-Jun-09 3:16 
QuestionPossible to have a two-way Associative Arrays Pin
ComplexLifeForm25-Jun-09 2:30
ComplexLifeForm25-Jun-09 2:30 
AnswerRe: Possible to have a two-way Associative Arrays Pin
Andy Moore25-Jun-09 6:09
Andy Moore25-Jun-09 6:09 
GeneralRe: Possible to have a two-way Associative Arrays Pin
Stuart Dootson25-Jun-09 6:10
professionalStuart Dootson25-Jun-09 6:10 
AnswerRe: Possible to have a two-way Associative Arrays Pin
Stuart Dootson25-Jun-09 6:09
professionalStuart Dootson25-Jun-09 6:09 
GeneralRe: Possible to have a two-way Associative Arrays Pin
Kevin McFarlane4-Jul-09 6:01
Kevin McFarlane4-Jul-09 6:01 
GeneralRe: Possible to have a two-way Associative Arrays Pin
Stuart Dootson4-Jul-09 7:49
professionalStuart Dootson4-Jul-09 7:49 
AnswerRe: Possible to have a two-way Associative Arrays Pin
ComplexLifeForm25-Jun-09 7:01
ComplexLifeForm25-Jun-09 7:01 
QuestionHow to Implement RPC in windows XP Pin
suthakar5618-Jun-09 18:45
suthakar5618-Jun-09 18:45 
AnswerRe: How to Implement RPC in windows XP Pin
Stuart Dootson18-Jun-09 22:05
professionalStuart Dootson18-Jun-09 22:05 
AnswerRe: How to Implement RPC in windows XP Pin
led mike19-Jun-09 5:25
led mike19-Jun-09 5:25 
GeneralRe: How to Implement RPC in windows XP Pin
suthakar5619-Jun-09 5:38
suthakar5619-Jun-09 5:38 
GeneralRe: How to Implement RPC in windows XP Pin
led mike19-Jun-09 5:53
led mike19-Jun-09 5:53 
GeneralRe: How to Implement RPC in windows XP Pin
Stuart Dootson19-Jun-09 12:46
professionalStuart Dootson19-Jun-09 12:46 
GeneralRe: How to Implement RPC in windows XP Pin
suthakar5619-Jun-09 22:30
suthakar5619-Jun-09 22:30 
GeneralRe: How to Implement RPC in windows XP Pin
Stuart Dootson20-Jun-09 14:09
professionalStuart Dootson20-Jun-09 14:09 

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.