diff --git a/fml/platform/win/wstring_conversion.cc b/fml/platform/win/wstring_conversion.cc index ef87f60e89e6b..6e4e36e8cf629 100644 --- a/fml/platform/win/wstring_conversion.cc +++ b/fml/platform/win/wstring_conversion.cc @@ -23,16 +23,4 @@ std::wstring Utf8ToWideString(const std::string_view str) { return converter.from_bytes(str.data()); } -std::u16string WideStringToUtf16(const std::wstring_view str) { - static_assert(sizeof(std::wstring::value_type) == - sizeof(std::u16string::value_type)); - return {begin(str), end(str)}; -} - -std::wstring Utf16ToWideString(const std::u16string_view str) { - static_assert(sizeof(std::wstring::value_type) == - sizeof(std::u16string::value_type)); - return {begin(str), end(str)}; -} - } // namespace fml diff --git a/fml/platform/win/wstring_conversion.h b/fml/platform/win/wstring_conversion.h index cc5dbb680ae60..4e7c110685491 100644 --- a/fml/platform/win/wstring_conversion.h +++ b/fml/platform/win/wstring_conversion.h @@ -16,12 +16,6 @@ std::string WideStringToUtf8(const std::wstring_view str); // string. std::wstring Utf8ToWideString(const std::string_view str); -// Returns a UTF-16 encoded equivalent of a UTF-16 encoded wide string. -std::u16string WideStringToUtf16(const std::wstring_view str); - -// Returns a UTF-16 encoded wide string equivalent of a UTF-16 string. -std::wstring Utf16ToWideString(const std::u16string_view str); - } // namespace fml #endif // FLUTTER_FML_PLATFORM_WIN_WSTRING_CONVERSION_H_ diff --git a/fml/platform/win/wstring_conversion_unittests.cc b/fml/platform/win/wstring_conversion_unittests.cc index 1f726720fc511..81af2594ce94c 100644 --- a/fml/platform/win/wstring_conversion_unittests.cc +++ b/fml/platform/win/wstring_conversion_unittests.cc @@ -9,7 +9,7 @@ namespace fml { namespace testing { -TEST(StringConversion, Utf8ToWideStringEmpty) { +TEST(StringConversion, Utf16ToWideStringEmpty) { EXPECT_EQ(Utf8ToWideString(""), L""); } @@ -33,29 +33,5 @@ TEST(StringConversion, WideStringToUtf8Unicode) { EXPECT_EQ(WideStringToUtf8(L"\x2603"), "\xe2\x98\x83"); } -TEST(StringConversion, WideStringToUtf16Empty) { - EXPECT_EQ(WideStringToUtf16(L""), u""); -} - -TEST(StringConversion, WideStringToUtf16Ascii) { - EXPECT_EQ(WideStringToUtf16(L"abc123"), u"abc123"); -} - -TEST(StringConversion, WideStringToUtf16Unicode) { - EXPECT_EQ(WideStringToUtf16(L"\xe2\x98\x83"), u"\xe2\x98\x83"); -} - -TEST(StringConversion, Utf16ToWideStringEmpty) { - EXPECT_EQ(Utf16ToWideString(u""), L""); -} - -TEST(StringConversion, Utf16ToWideStringAscii) { - EXPECT_EQ(Utf16ToWideString(u"abc123"), L"abc123"); -} - -TEST(StringConversion, Utf16ToWideStringUtf8Unicode) { - EXPECT_EQ(Utf16ToWideString(u"\xe2\x98\x83"), L"\xe2\x98\x83"); -} - } // namespace testing } // namespace fml diff --git a/third_party/accessibility/ax/BUILD.gn b/third_party/accessibility/ax/BUILD.gn index fc07993a3fe70..d03e3cde122de 100644 --- a/third_party/accessibility/ax/BUILD.gn +++ b/third_party/accessibility/ax/BUILD.gn @@ -106,7 +106,6 @@ source_set("ax") { "oleacc.lib", "uiautomationcore.lib", ] - deps = [ "//flutter/fml:string_conversion" ] } public_deps = [ diff --git a/third_party/accessibility/ax/ax_node_position_unittest.cc b/third_party/accessibility/ax/ax_node_position_unittest.cc index b5b993d4723a6..18677f3697eae 100644 --- a/third_party/accessibility/ax/ax_node_position_unittest.cc +++ b/third_party/accessibility/ax/ax_node_position_unittest.cc @@ -19,7 +19,6 @@ #include "ax/ax_tree_id.h" #include "ax/ax_tree_update.h" #include "ax/test_ax_tree_manager.h" -#include "flutter/fml/platform/win/wstring_conversion.h" #include "gtest/gtest.h" namespace ui { @@ -29,6 +28,10 @@ using TestPositionRange = AXRange>; namespace { +std::u16string WideToUTF16(const std::wstring wide) { + return std::u16string(wide.begin(), wide.end()); +} + constexpr AXNode::AXID ROOT_ID = 1; constexpr AXNode::AXID BUTTON_ID = 2; constexpr AXNode::AXID CHECK_BOX_ID = 3; @@ -40,20 +43,20 @@ constexpr AXNode::AXID STATIC_TEXT2_ID = 8; constexpr AXNode::AXID INLINE_BOX2_ID = 9; // A group of basic and extended characters. -constexpr const char16_t* kGraphemeClusters[] = { +constexpr const wchar_t* kGraphemeClusters[] = { // The English word "hey" consisting of four ASCII characters. - u"h", - u"e", - u"y", + L"h", + L"e", + L"y", // A Hindi word (which means "Hindi") consisting of two Devanagari // grapheme clusters. - u"\x0939\x093F", - u"\x0928\x094D\x0926\x0940", + L"\x0939\x093F", + L"\x0928\x094D\x0926\x0940", // A Thai word (which means "feel") consisting of three Thai grapheme // clusters. - u"\x0E23\x0E39\x0E49", - u"\x0E2A\x0E36", - u"\x0E01", + L"\x0E23\x0E39\x0E49", + L"\x0E2A\x0E36", + L"\x0E01", }; class AXPositionTest : public testing::Test, public TestAXTreeManager { @@ -416,7 +419,7 @@ std::unique_ptr AXPositionTest::CreateMultilingualDocument( std::u16string english_text; for (int i = 0; i < 3; ++i) { - std::u16string grapheme = kGraphemeClusters[i]; + std::u16string grapheme = WideToUTF16(kGraphemeClusters[i]); EXPECT_EQ(1u, grapheme.length()) << "All English characters should be one UTF16 code unit in length."; text_offsets->push_back(text_offsets->back() + @@ -426,7 +429,7 @@ std::unique_ptr AXPositionTest::CreateMultilingualDocument( std::u16string hindi_text; for (int i = 3; i < 5; ++i) { - std::u16string grapheme = kGraphemeClusters[i]; + std::u16string grapheme = WideToUTF16(kGraphemeClusters[i]); EXPECT_LE(2u, grapheme.length()) << "All Hindi characters should be two " "or more UTF16 code units in length."; text_offsets->push_back(text_offsets->back() + @@ -436,7 +439,7 @@ std::unique_ptr AXPositionTest::CreateMultilingualDocument( std::u16string thai_text; for (int i = 5; i < 8; ++i) { - std::u16string grapheme = kGraphemeClusters[i]; + std::u16string grapheme = WideToUTF16(kGraphemeClusters[i]); EXPECT_LT(0u, grapheme.length()) << "One of the Thai characters should be one UTF16 code unit, " "whilst others should be two or more."; @@ -615,7 +618,7 @@ TEST_F(AXPositionTest, ToString) { AXNodeData static_text_data_2; static_text_data_2.id = 3; static_text_data_2.role = ax::mojom::Role::kStaticText; - static_text_data_2.SetName(u"\xfffc"); + static_text_data_2.SetName(WideToUTF16(L"\xfffc")); AXNodeData static_text_data_3; static_text_data_3.id = 4; @@ -873,7 +876,7 @@ TEST_F(AXPositionTest, GetTextFromNullPosition) { TestPositionType text_position = AXNodePosition::CreateNullPosition(); ASSERT_NE(nullptr, text_position); ASSERT_TRUE(text_position->IsNullPosition()); - ASSERT_EQ(u"", text_position->GetText()); + ASSERT_EQ(WideToUTF16(L""), text_position->GetText()); } TEST_F(AXPositionTest, GetTextFromRoot) { @@ -882,7 +885,7 @@ TEST_F(AXPositionTest, GetTextFromRoot) { ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); ASSERT_TRUE(text_position->IsTextPosition()); - ASSERT_EQ(u"Line 1\nLine 2", text_position->GetText()); + ASSERT_EQ(WideToUTF16(L"Line 1\nLine 2"), text_position->GetText()); } TEST_F(AXPositionTest, GetTextFromButton) { @@ -891,7 +894,7 @@ TEST_F(AXPositionTest, GetTextFromButton) { ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); ASSERT_TRUE(text_position->IsTextPosition()); - ASSERT_EQ(u"", text_position->GetText()); + ASSERT_EQ(WideToUTF16(L""), text_position->GetText()); } TEST_F(AXPositionTest, GetTextFromCheckbox) { @@ -900,7 +903,7 @@ TEST_F(AXPositionTest, GetTextFromCheckbox) { ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); ASSERT_TRUE(text_position->IsTextPosition()); - ASSERT_EQ(u"", text_position->GetText()); + ASSERT_EQ(WideToUTF16(L""), text_position->GetText()); } TEST_F(AXPositionTest, GetTextFromTextField) { @@ -909,7 +912,7 @@ TEST_F(AXPositionTest, GetTextFromTextField) { ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); ASSERT_TRUE(text_position->IsTextPosition()); - ASSERT_EQ(u"Line 1\nLine 2", text_position->GetText()); + ASSERT_EQ(WideToUTF16(L"Line 1\nLine 2"), text_position->GetText()); } TEST_F(AXPositionTest, GetTextFromStaticText) { @@ -918,7 +921,7 @@ TEST_F(AXPositionTest, GetTextFromStaticText) { ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); ASSERT_TRUE(text_position->IsTextPosition()); - ASSERT_EQ(u"Line 1", text_position->GetText()); + ASSERT_EQ(WideToUTF16(L"Line 1"), text_position->GetText()); } TEST_F(AXPositionTest, GetTextFromInlineTextBox) { @@ -927,7 +930,7 @@ TEST_F(AXPositionTest, GetTextFromInlineTextBox) { ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); ASSERT_TRUE(text_position->IsTextPosition()); - ASSERT_EQ(u"Line 1", text_position->GetText()); + ASSERT_EQ(WideToUTF16(L"Line 1"), text_position->GetText()); } TEST_F(AXPositionTest, GetTextFromLineBreak) { @@ -936,7 +939,7 @@ TEST_F(AXPositionTest, GetTextFromLineBreak) { ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); ASSERT_TRUE(text_position->IsTextPosition()); - ASSERT_EQ(u"\n", text_position->GetText()); + ASSERT_EQ(WideToUTF16(L"\n"), text_position->GetText()); } TEST_F(AXPositionTest, GetMaxTextOffsetFromNullPosition) { @@ -1103,7 +1106,7 @@ TEST_F(AXPositionTest, GetMaxTextOffsetAndGetTextWithGeneratedContent) { ASSERT_NE(nullptr, text_position); EXPECT_TRUE(text_position->IsTextPosition()); EXPECT_EQ(38, text_position->MaxTextOffset()); - EXPECT_EQ(u"Placeholder from generated content3.14", + EXPECT_EQ(WideToUTF16(L"Placeholder from generated content3.14"), text_position->GetText()); } @@ -7709,10 +7712,10 @@ TEST_F(AXPositionTest, EmptyObjectReplacedByCharacterTextNavigation) { GetTreeID(), root_1.id, 0 /* text_offset */, ax::mojom::TextAffinity::kDownstream); - expected_text = - std::u16string(u"Hello ") + AXNodePosition::kEmbeddedCharacter + - std::u16string(u" world3.14") + AXNodePosition::kEmbeddedCharacter + - std::u16string(u"hey") + AXNodePosition::kEmbeddedCharacter; + expected_text = WideToUTF16(L"Hello ") + AXNodePosition::kEmbeddedCharacter + + WideToUTF16(L" world3.14") + + AXNodePosition::kEmbeddedCharacter + WideToUTF16(L"hey") + + AXNodePosition::kEmbeddedCharacter; ASSERT_EQ(expected_text, position->GetText()); // MaxTextOffset() with an embedded object replacement character. diff --git a/third_party/accessibility/ax/platform/ax_platform_node_textprovider_win_unittest.cc b/third_party/accessibility/ax/platform/ax_platform_node_textprovider_win_unittest.cc index b3d1c98a15e04..2b3a846da46e9 100644 --- a/third_party/accessibility/ax/platform/ax_platform_node_textprovider_win_unittest.cc +++ b/third_party/accessibility/ax/platform/ax_platform_node_textprovider_win_unittest.cc @@ -349,7 +349,7 @@ TEST_F(AXPlatformNodeTextProviderTest, base::win::ScopedBstr text_content; EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetText(-1, text_content.Receive())); - EXPECT_EQ(fml::WideStringToUtf16(text_content.Get()), + EXPECT_EQ(base::WideToUTF16(text_content.Get()), u"Dialog label.Dialog description." + kEmbeddedCharacterAsString + u"ok.Some more detail " + u"about dialog."); diff --git a/third_party/accessibility/ax/platform/ax_platform_node_textrangeprovider_win.cc b/third_party/accessibility/ax/platform/ax_platform_node_textrangeprovider_win.cc index 71f72d3395085..2c7cca0e2e81b 100644 --- a/third_party/accessibility/ax/platform/ax_platform_node_textrangeprovider_win.cc +++ b/third_party/accessibility/ax/platform/ax_platform_node_textrangeprovider_win.cc @@ -13,7 +13,6 @@ #include "ax/platform/ax_platform_node_win.h" #include "ax/platform/ax_platform_tree_manager.h" #include "base/win/variant_vector.h" -#include "flutter/fml/platform/win/wstring_conversion.h" #define UIA_VALIDATE_TEXTRANGEPROVIDER_CALL() \ if (!GetOwner() || !GetOwner()->GetDelegate() || !start() || \ @@ -484,7 +483,7 @@ HRESULT AXPlatformNodeTextRangeProviderWin::FindText( ScopedAXEmbeddedObjectBehaviorSetter ax_embedded_object_behavior( AXEmbeddedObjectBehavior::kSuppressCharacter); - std::u16string search_string = fml::WideStringToUtf16(string); + std::u16string search_string = base::WideToUTF16(string); if (search_string.length() <= 0) return E_INVALIDARG; @@ -704,7 +703,7 @@ HRESULT AXPlatformNodeTextRangeProviderWin::GetText(int max_count, BSTR* text) { if (max_count < -1) return E_INVALIDARG; - std::wstring full_text = fml::Utf16ToWideString(GetString(max_count)); + std::wstring full_text = base::UTF16ToWide(GetString(max_count)); if (!full_text.empty()) { size_t length = full_text.length(); diff --git a/third_party/accessibility/ax/platform/ax_platform_node_win.cc b/third_party/accessibility/ax/platform/ax_platform_node_win.cc index fcc7b8b3b6486..b00f5d2c58eaf 100644 --- a/third_party/accessibility/ax/platform/ax_platform_node_win.cc +++ b/third_party/accessibility/ax/platform/ax_platform_node_win.cc @@ -38,7 +38,6 @@ #include "base/logging.h" #include "base/win/atl_module.h" #include "base/win/display.h" -#include "flutter/fml/platform/win/wstring_conversion.h" #include "gfx/geometry/rect_conversions.h" // From ax.constants.mojom @@ -964,7 +963,7 @@ IFACEMETHODIMP AXPlatformNodeWin::get_accDefaultAction(VARIANT var_id, return S_FALSE; } - *def_action = ::SysAllocString(fml::Utf16ToWideString(action_verb).c_str()); + *def_action = ::SysAllocString(base::UTF16ToWide(action_verb).c_str()); BASE_DCHECK(def_action); return S_OK; } @@ -1055,7 +1054,7 @@ IFACEMETHODIMP AXPlatformNodeWin::get_accName(VARIANT var_id, BSTR* name_bstr) { if (name.empty() && !has_name) return S_FALSE; - *name_bstr = ::SysAllocString(fml::Utf16ToWideString(name).c_str()); + *name_bstr = ::SysAllocString(base::UTF16ToWide(name).c_str()); return S_OK; } @@ -1750,7 +1749,7 @@ IFACEMETHODIMP AXPlatformNodeWin::SetValue(LPCWSTR value) { AXActionData data; data.action = ax::mojom::Action::kSetValue; - data.value = base::UTF16ToUTF8(fml::WideStringToUtf16(value)); + data.value = base::UTF16ToUTF8(base::WideToUTF16(value)); if (GetDelegate()->AccessibilityPerformAction(data)) return S_OK; return E_FAIL; @@ -2133,20 +2132,20 @@ HRESULT AXPlatformNodeWin::GetPropertyValueImpl(PROPERTYID property_id, switch (property_id) { case UIA_AriaPropertiesPropertyId: result->vt = VT_BSTR; - result->bstrVal = ::SysAllocString( - fml::Utf16ToWideString(ComputeUIAProperties()).c_str()); + result->bstrVal = + ::SysAllocString(base::UTF16ToWide(ComputeUIAProperties()).c_str()); break; case UIA_AriaRolePropertyId: result->vt = VT_BSTR; result->bstrVal = - ::SysAllocString(fml::Utf16ToWideString(UIAAriaRole()).c_str()); + ::SysAllocString(base::UTF16ToWide(UIAAriaRole()).c_str()); break; case UIA_AutomationIdPropertyId: V_VT(result) = VT_BSTR; V_BSTR(result) = ::SysAllocString( - fml::Utf16ToWideString(GetDelegate()->GetAuthorUniqueId()).c_str()); + base::UTF16ToWide(GetDelegate()->GetAuthorUniqueId()).c_str()); break; case UIA_ClassNamePropertyId: @@ -2315,8 +2314,8 @@ HRESULT AXPlatformNodeWin::GetPropertyValueImpl(PROPERTYID property_id, std::u16string localized_control_type = GetRoleDescription(); if (!localized_control_type.empty()) { result->vt = VT_BSTR; - result->bstrVal = ::SysAllocString( - fml::Utf16ToWideString(localized_control_type).c_str()); + result->bstrVal = + ::SysAllocString(base::UTF16ToWide(localized_control_type).c_str()); } // If a role description has not been provided, leave as VT_EMPTY. // UIA core handles Localized Control type for some built-in types and @@ -2467,7 +2466,7 @@ HRESULT AXPlatformNodeWin::GetPropertyValueImpl(PROPERTYID property_id, if (!localized_landmark_type.empty()) { result->vt = VT_BSTR; result->bstrVal = ::SysAllocString( - fml::Utf16ToWideString(localized_landmark_type).c_str()); + base::UTF16ToWide(localized_landmark_type).c_str()); } break; } @@ -2526,7 +2525,7 @@ HRESULT AXPlatformNodeWin::GetPropertyValueImpl(PROPERTYID property_id, // convention here and when we fire events via ::NotifyWinEvent(). result->vt = VT_BSTR; result->bstrVal = ::SysAllocString( - fml::Utf16ToWideString(base::NumberToString16(-GetUniqueId())).c_str()); + base::UTF16ToWide(base::NumberToString16(-GetUniqueId())).c_str()); } return S_OK; @@ -5315,7 +5314,7 @@ BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin* target) { value_text = base::NumberToString16(red * 100 / 255) + u"% red " + base::NumberToString16(green * 100 / 255) + u"% green " + base::NumberToString16(blue * 100 / 255) + u"% blue"; - BSTR value = ::SysAllocString(fml::Utf16ToWideString(value_text).c_str()); + BSTR value = ::SysAllocString(base::UTF16ToWide(value_text).c_str()); BASE_DCHECK(value); return value; } @@ -5326,7 +5325,7 @@ BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin* target) { if (target->GetData().role == ax::mojom::Role::kRootWebArea || target->GetData().role == ax::mojom::Role::kWebArea) { result = base::UTF8ToUTF16(target->GetDelegate()->GetTreeData().url); - BSTR value = ::SysAllocString(fml::Utf16ToWideString(result).c_str()); + BSTR value = ::SysAllocString(base::UTF16ToWide(result).c_str()); BASE_DCHECK(value); return value; } @@ -5336,7 +5335,7 @@ BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin* target) { // if (target->GetData().role == ax::mojom::Role::kLink) { result = target->GetString16Attribute(ax::mojom::StringAttribute::kUrl); - BSTR value = ::SysAllocString(fml::Utf16ToWideString(result).c_str()); + BSTR value = ::SysAllocString(base::UTF16ToWide(result).c_str()); BASE_DCHECK(value); return value; } @@ -5351,7 +5350,7 @@ BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin* target) { if (target->GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, &fval)) { result = base::NumberToString16(fval); - BSTR value = ::SysAllocString(fml::Utf16ToWideString(result).c_str()); + BSTR value = ::SysAllocString(base::UTF16ToWide(result).c_str()); BASE_DCHECK(value); return value; } @@ -5360,7 +5359,7 @@ BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin* target) { if (result.empty() && target->IsRichTextField()) result = target->GetInnerText(); - BSTR value = ::SysAllocString(fml::Utf16ToWideString(result).c_str()); + BSTR value = ::SysAllocString(base::UTF16ToWide(result).c_str()); BASE_DCHECK(value); return value; } @@ -5373,7 +5372,7 @@ HRESULT AXPlatformNodeWin::GetStringAttributeAsBstr( if (!GetString16Attribute(attribute, &str)) return S_FALSE; - *value_bstr = ::SysAllocString(fml::Utf16ToWideString(str).c_str()); + *value_bstr = ::SysAllocString(base::UTF16ToWide(str).c_str()); BASE_DCHECK(*value_bstr); return S_OK; @@ -5381,7 +5380,7 @@ HRESULT AXPlatformNodeWin::GetStringAttributeAsBstr( HRESULT AXPlatformNodeWin::GetNameAsBstr(BSTR* value_bstr) const { std::u16string str = GetNameAsString16(); - *value_bstr = ::SysAllocString(fml::Utf16ToWideString(str).c_str()); + *value_bstr = ::SysAllocString(base::UTF16ToWide(str).c_str()); BASE_DCHECK(*value_bstr); return S_OK; } @@ -5491,14 +5490,14 @@ BSTR AXPlatformNodeWin::GetFontNameAttributeAsBSTR() const { const std::u16string string = GetInheritedString16Attribute(ax::mojom::StringAttribute::kFontFamily); - return ::SysAllocString(fml::Utf16ToWideString(string).c_str()); + return ::SysAllocString(base::UTF16ToWide(string).c_str()); } BSTR AXPlatformNodeWin::GetStyleNameAttributeAsBSTR() const { std::u16string style_name = GetDelegate()->GetStyleNameAttributeAsLocalizedString(); - return ::SysAllocString(fml::Utf16ToWideString(style_name).c_str()); + return ::SysAllocString(base::UTF16ToWide(style_name).c_str()); } TextDecorationLineStyle AXPlatformNodeWin::GetUIATextDecorationStyle( diff --git a/third_party/accessibility/base/string_utils.cc b/third_party/accessibility/base/string_utils.cc index 963f7d581d4f7..61e0a4a257f4a 100644 --- a/third_party/accessibility/base/string_utils.cc +++ b/third_party/accessibility/base/string_utils.cc @@ -72,6 +72,14 @@ std::string UTF16ToUTF8(std::u16string src) { return fml::Utf16ToUtf8(src); } +std::u16string WideToUTF16(const std::wstring& src) { + return std::u16string(src.begin(), src.end()); +} + +std::wstring UTF16ToWide(const std::u16string& src) { + return std::wstring(src.begin(), src.end()); +} + std::u16string NumberToString16(float number) { return ASCIIToUTF16(NumberToString(number)); } diff --git a/third_party/accessibility/base/string_utils.h b/third_party/accessibility/base/string_utils.h index ceddfbf2b0b15..6e3c6c6153ce9 100644 --- a/third_party/accessibility/base/string_utils.h +++ b/third_party/accessibility/base/string_utils.h @@ -26,6 +26,8 @@ std::string StringPrintf(const std::string& format, Args... args) { std::u16string ASCIIToUTF16(std::string src); std::u16string UTF8ToUTF16(std::string src); std::string UTF16ToUTF8(std::u16string src); +std::u16string WideToUTF16(const std::wstring& src); +std::wstring UTF16ToWide(const std::u16string& src); std::u16string NumberToString16(unsigned int number); std::u16string NumberToString16(int32_t number);