summaryrefslogtreecommitdiff
path: root/client/main.cpp
diff options
context:
space:
mode:
authorSpencer Low <CompareAndSwap@gmail.com>2015-11-12 15:20:15 -0800
committerSpencer Low <CompareAndSwap@gmail.com>2015-11-12 17:13:08 -0800
commit10ea4b609bf1d64834f65272b08b7878aedd8323 (patch)
treed497eb61563f4d8b0cfd541b6c378edc98bc0eed /client/main.cpp
parent409bc742ba9ae2c2f3dcf83fcd71b454a94691aa (diff)
downloadadb-10ea4b609bf1d64834f65272b08b7878aedd8323.tar.gz
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 <CompareAndSwap@gmail.com>
Diffstat (limited to 'client/main.cpp')
-rw-r--r--client/main.cpp7
1 files changed, 6 insertions, 1 deletions
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";