From 10ea4b609bf1d64834f65272b08b7878aedd8323 Mon Sep 17 00:00:00 2001 From: Spencer Low Date: Thu, 12 Nov 2015 15:20:15 -0800 Subject: adb: win32: remove widen()/narrow() in favor of UTF8ToWide()/WideToUTF8() Now that we have a more standardized API (also available in Chromium), switch to it. Another benefit is real error handling instead of just killing the process on invalid Unicode. Make UTF8ToWide()/WideToUTF8() set errno to EILSEQ on bad input. This is the same error code that wcsrtombs(3) uses. Update the unittest to check for EILSEQ. Change-Id: Ie92acf74d37adaea116cf610c1bf8cd433741e16 Signed-off-by: Spencer Low --- client/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'client/main.cpp') diff --git a/client/main.cpp b/client/main.cpp index a225a53..8d01af3 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -58,7 +58,12 @@ static std::string GetLogFilePath() { SystemErrorCodeToString(GetLastError()).c_str()); } - return narrow(temp_path) + log_name; + std::string temp_path_utf8; + if (!android::base::WideToUTF8(temp_path, &temp_path_utf8)) { + fatal_errno("cannot convert temporary file path from UTF-16 to UTF-8"); + } + + return temp_path_utf8 + log_name; } #else static const char kNullFileName[] = "/dev/null"; -- cgit v1.2.3