# std::text_encoding::environment

> C++ Atlas: `cppatlas.com/w/cpp/text/text_encoding/environment` | Source: https://en.cppreference.com/w/cpp/text/text_encoding/environment | Domain: Text processing | Standards: C++26

Constructs a new text_encoding object representing the environment encoding that refers to the implementation-defined character encoding scheme of the execution environment.

## Official Specification Summary (cppreference)

```cpp
static text_encoding environment(); // (since C++26)
```

Constructs a new `text_encoding` object representing the environment encoding that refers to the implementation-defined character encoding scheme of the execution environment. The execution environment at runtime is the environment in which the program is run.

The environment encoding in the execution environment is distinct from the encoding of execution character set which is locale-specific. In other words, the environment encoding remains locale-independent, that is, the value returned by `environment()` is not affected by calls to the functions (e.g. `std::setlocale` and POSIX function `setenv()`) which can modify the environment.

This function is deleted unless the `CHAR_BIT` is `8`.

### Parameters

(none)

### Return value

The object holding the representation of the environment character encoding.

### Notes

The environment encoding may differ from the global locale-associated encoding that is accessible via `std::locale().encoding()`.

On Windows platforms, the environment encoding can be determined by `GetACP()` and then mapped to MIBenum values.

On POSIX platforms, the environment encoding is associated with the POSIX locale `""` which can be implemented to correspond to a value of `nl_langinfo_l()` when the environment locale `""` is set before the global C++ locale is set to `"C"` at program startup.

### Example

> Note: This section is incomplete Reason: no example

### See also

- [`encoding`](https://en.cppreference.com/w/cpp/locale/locale/encoding) (C++26): returns the character encoding scheme associated with the locale (public member function of `std::locale`)

---
Attribution: content from https://en.cppreference.com/w/cpp/text/text_encoding/environment (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.