
- The C Standard Library
- The C Standard Library
- The C++ Standard Library
- C++ Library - Home
- C++ Library - <fstream>
- C++ Library - <iomanip>
- C++ Library - <ios>
- C++ Library - <iosfwd>
- C++ Library - <iostream>
- C++ Library - <istream>
- C++ Library - <ostream>
- C++ Library - <sstream>
- C++ Library - <streambuf>
- C++ Library - <atomic>
- C++ Library - <complex>
- C++ Library - <exception>
- C++ Library - <functional>
- C++ Library - <limits>
- C++ Library - <locale>
- C++ Library - <memory>
- C++ Library - <new>
- C++ Library - <numeric>
- C++ Library - <regex>
- C++ Library - <stdexcept>
- C++ Library - <string>
- C++ Library - <thread>
- C++ Library - <tuple>
- C++ Library - <typeinfo>
- C++ Library - <utility>
- C++ Library - <valarray>
- The C++ STL Library
- C++ Library - <array>
- C++ Library - <bitset>
- C++ Library - <deque>
- C++ Library - <forward_list>
- C++ Library - <list>
- C++ Library - <map>
- C++ Library - <queue>
- C++ Library - <set>
- C++ Library - <stack>
- C++ Library - <unordered_map>
- C++ Library - <unordered_set>
- C++ Library - <vector>
- C++ Library - <algorithm>
- C++ Library - <iterator>
- C++ Programming Resources
- C++ Programming Tutorial
- C++ Useful Resources
- C++ Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Locale Library - encoding
Description
It 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.
Declaration
Following is the declaration for std::ctype::encoding.
C++98
int encoding() const throw();
C++11
int encoding() const throw();
Parameters
none
Return Value
It returns the width of an internal character in terms of external characters, if this is a fixed value.
Exceptions
No-throw guarantee − never throws exceptions.
Data races
The facet object is accessed.
Example
In below example explains about std::ctype::encoding.
#include <iostream> #include <locale> 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; }
Let us compile and run the above program, this will produce the following result −
Characteristics of codecvt<wchar_t,char,mbstate_t>: Encoding: 1 Always noconv: 0 Max length: 1
locale.htm
Advertisements