std::basic_ios::imbue - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::basic_ios::imbue

From cppreference.com
< cpp‎ | io‎ | basic ios

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

### [edit] Parameters

loc | - | the new locale

### [edit] Return value

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

### [edit] Exceptions

(none)

### [edit] Example

Run this code

    #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

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_ios/imbue&oldid=67265"