GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::wstring_convert::converted(3) C++ Standard Libary std::wstring_convert::converted(3)

std::wstring_convert::converted - std::wstring_convert::converted


Defined in header <locale>
std::size_t converted() const noexcept;


Returns the number of source characters that were processed by the most recent
from_bytes() or to_bytes().


The number of characters consumed by the most recent conversion operation.

// Run this code


#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
int main()
{
std::string utf8 = u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
// or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
std::cout << "original UTF-8 string size: " << utf8.size() << '\n';


// the UTF-8 - UTF-32 standard conversion facet
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> cvt;


// UTF-8 to UTF-32
std::u32string utf32 = cvt.from_bytes(utf8);
std::cout << "UTF-32 string size: " << utf32.size() << '\n';
std::cout << "converted() == " << cvt.converted() << '\n';
// UTF-32 to UTF-8
utf8 = cvt.to_bytes(utf32);
std::cout << "new UTF-8 string size: " << utf8.size() << '\n';
std::cout << "converted() == " << cvt.converted() << '\n';
}


original UTF-8 string size: 10
UTF-32 string size: 4
converted() == 10
new UTF-8 string size: 10
converted() == 4


Defect reports


The following behavior-changing defect reports were applied retroactively to
previously published C++ standards.


DR Applied to Behavior as published Correct behavior
LWG 2174 C++11 wstring_convert::converted was not required to required
be noexcept


to_bytes converts a wide string into a byte string
(public member function)
from_bytes converts a byte string into a wide string
(public member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.