| | 348 | //CHECKME: I just copied the code above, and have no idea whether it |
|---|
| | 349 | //is correct... (JMarc) |
|---|
| | 350 | idocstream & 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 | |
|---|