[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/locale/codecvt/encoding [Back]  [Original]

std::codecvt::encoding, std::codecvt::do_encoding cppreference.com
cppreference.com

std::codecvt::encoding, std::codecvt::do_encoding

cppreference.com

<metanoindex/>

<tbody> </tbody>
public: int encoding() const
(1)
protected: int do_encoding() const
(2)

1)

-, do_encoding - .
:
public member function, calls the member function do_encoding of the most derived class.
Google.
. .

2) if the encoding represented by this codecvt facet maps each internal character to the same, constant number of external characters, returns that number. If the encoding is variable-length (e.g. UTF-8 or UTF-16), returns 0. If the encoding is state-dependent, returns -1.

The exact number of externT characters that correspond to one internT character, if constant. 0 if the number varies, -1 if the encoding is state-dependent.

std::codecvt<char, char, std::mbstate_t> 1
:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> returns 1
Google.
. .

noexcept:  
noexcept
  

#include <locale>
#include <iostream>
int main()
{
    std::cout << "en_US.utf8 is a variable-length encoding, encoding() returns "
              << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale("en_US.utf8")
              ).encoding() << '\n';

    std::cout << "zh_CN.gb18030 is also variable-length, encoding() == "
              << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale("zh_CN.gb18030")
              ).encoding() << '\n';

    std::cout << "ru_RU.koi8r is a single-byte encoding encoding() == "
              << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale("ru_RU.koi8r")
              ).encoding() << '\n';
}

:

en_US.utf8 is a variable-length encoding, encoding() returns 0
zh_CN.gb18030 is also variable-length, encoding() == 0
ru_RU.koi8r is a single-byte encoding encoding() == 1

.

MB_CUR_MAX
C
() []
externT , internT
:
returns the maximum number of externT characters that could be converted into a single internT character
Google.
. .

(virtual protected -) []

Web Proxy Viewer  |  New URL  |  Original Page