Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

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

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).

NotebookLM
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

May throw implementation-defined exceptions.

Example

example.cpp
#include <iostream>
#include <locale>
#include <sstream>
 
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

Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.