utf_ostream_operators.cc (1033B)
1 // Copyright 2023 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "base/strings/utf_ostream_operators.h" 6 7 #include "base/strings/utf_string_conversions.h" 8 9 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { 10 return out << (wstr ? std::wstring_view(wstr) : std::wstring_view()); 11 } 12 13 std::ostream& std::operator<<(std::ostream& out, std::wstring_view wstr) { 14 return out << base::WideToUTF8(wstr); 15 } 16 17 std::ostream& std::operator<<(std::ostream& out, const std::wstring& wstr) { 18 return out << std::wstring_view(wstr); 19 } 20 21 std::ostream& std::operator<<(std::ostream& out, const char16_t* str16) { 22 return out << (str16 ? std::u16string_view(str16) : std::u16string_view()); 23 } 24 25 std::ostream& std::operator<<(std::ostream& out, std::u16string_view str16) { 26 return out << base::UTF16ToUTF8(str16); 27 } 28 29 std::ostream& std::operator<<(std::ostream& out, const std::u16string& str16) { 30 return out << std::u16string_view(str16); 31 }