A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/locale/codecvt/encoding/ below:

public member function

<locale>

std::codecvt::encoding
int encoding() const throw();
int encoding() const noexcept;

Return encoding width

Returns the width of an internal character in terms of external characters, if this is a fixed value.

Otherwise, if this is a variable value, the function returns 0.

Alternatively, if the encoding of an external sequence is state-dependent, the function returns -1.

Internally, this function simply calls the virtual protected member do_encoding, which behaves as described above by default.



Parameters none

Return value One of the following, describing how external characters are encoded:
value interpretation 0 Characters have a variable width, each with a maximum length of max_length. -1 Encoding is state-dependent, possibly with additional shift codes beyond max_length per character. other values Fixed amount of external characters equivalent to one internal character
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// codecvt::encoding example
#include <iostream>       // std::cout
#include <locale>         // std::locale, std::codecvt, std::use_facet

int main ()
{
  std::locale loc;

  const std::codecvt<wchar_t,char,mbstate_t>& myfacet = 
    std::use_facet<std::codecvt<wchar_t,char,mbstate_t> >(loc);

  std::cout << "Characteristics of codecvt<wchar_t,char,mbstate_t>:\n";
  std::cout << "Encoding: " << myfacet.encoding() << '\n';
  std::cout << "Always noconv: " << myfacet.always_noconv() << '\n';
  std::cout << "Max length: " << myfacet.max_length() << '\n';
  return 0;
}

Possible output:
Characteristics of codecvt<wchar_t,char,mbstate_t>:
Encoding: 0
Always noconv: 0
Max length: 5


Data races The facet object is accessed.

Exception safetyNo-throw guarantee: never throws exceptions.

See also
codecvt::length
Return length of translated sequence (public member function)
codecvt::max_length
Return max length of one character (public member function)
codecvt::do_encoding
Return encoding width [virtual] (protected virtual member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4