Changeset 27579

Show
Ignore:
Timestamp:
11/16/08 20:25:26 (2 months ago)
Author:
lasgouttes
Message:

add support for changing encoding on idocstream

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lyx-devel/trunk/src/support/docstream.cpp

    r27530 r27579  
    346346 
    347347 
     348//CHECKME: I just copied the code above, and have no idea whether it 
     349//is correct... (JMarc) 
     350idocstream & operator<<(idocstream & is, SetEnc e) 
     351{ 
     352        if (has_facet<iconv_codecvt_facet>(is.rdbuf()->getloc())) { 
     353                // This stream must be a file stream, since we never imbue 
     354                // any other stream with a locale having a iconv_codecvt_facet. 
     355                // Flush the stream so that all pending output is written 
     356                // with the old encoding. 
     357                //is.flush(); 
     358                locale locale(is.rdbuf()->getloc(), 
     359                        new iconv_codecvt_facet(e.encoding, ios_base::in)); 
     360                // FIXME Does changing the codecvt facet of an open file 
     361                // stream always work? It does with gcc 4.1, but I have read 
     362                // somewhere that it does not with MSVC. 
     363                // What does the standard say? 
     364                is.imbue(locale); 
     365        } 
     366        return is; 
     367} 
     368 
     369 
    348370#if ! defined(USE_WCHAR_T) 
    349371odocstream & operator<<(odocstream & os, char c) 
  • lyx-devel/trunk/src/support/docstream.h

    r27530 r27579  
    9191 */ 
    9292odocstream & operator<<(odocstream & os, SetEnc e); 
     93idocstream & operator<<(idocstream & os, SetEnc e); 
    9394 
    9495}