std::basic_ios<CharT,Traits>::imbue

From cppreference.com
< cpp‎ | io‎ | basic ios
 
 
Input/output library
I/O manipulators
C-style I/O
Buffers
(deprecated in C++98)
Streams
Abstractions
File I/O
String I/O
Array I/O
(deprecated in C++98)
(deprecated in C++98)
(deprecated in C++98)
Synchronized Output
Types
Error category interface
(C++11)
 
 
std::locale imbue( const std::locale& loc );

Replaces the current locale. Effectively calls ios_base::imbue(loc) and if there is an associated stream buffer (rdbuf() != 0), then calls rdbuf()->pubimbue(loc).

Parameters

loc - the new locale

Return value

The previous locale, as returned by ios_base::imbue(loc).

Exceptions

(none)

Example

#include <iostream>
#include <sstream>
#include <locale>
 
int main()
{
    std::istringstream iss;
    iss.imbue(std::locale("en_US.UTF8"));
 
    std::cout << "Current locale: " << iss.getloc().name() << '\n';
 
    iss.imbue(std::locale());
    std::cout << "Global locale : " << iss.getloc().name() << '\n';
}

Output:

Current locale: en_US.UTF8
Global locale : C