AAPT2: Remove usage of u16string
For legacy reasons, we kept around the use of UTF-16 internally
in AAPT2. We don't need this and this CL removes all instances of
std::u16string and StringPiece16. The only places still needed
are when interacting with the ResTable APIs that only operate in
UTF16.
Change-Id: I492475b84bb9014fa13bf992cff447ee7a5fe588
diff --git a/tools/aapt2/flatten/TableFlattener.cpp b/tools/aapt2/flatten/TableFlattener.cpp
index 28a7928..5fbb0fe 100644
--- a/tools/aapt2/flatten/TableFlattener.cpp
+++ b/tools/aapt2/flatten/TableFlattener.cpp
@@ -25,6 +25,7 @@
#include <android-base/macros.h>
#include <algorithm>
+#include <sstream>
#include <type_traits>
#include <numeric>
@@ -231,7 +232,8 @@
}
// Copy the package name in device endianness.
- strcpy16_htod(pkgHeader->name, arraysize(pkgHeader->name), mPackage->name);
+ strcpy16_htod(pkgHeader->name, arraysize(pkgHeader->name),
+ util::utf8ToUtf16(mPackage->name));
// Serialize the types. We do this now so that our type and key strings
// are populated. We write those first.
@@ -423,9 +425,9 @@
// If there is a gap in the type IDs, fill in the StringPool
// with empty values until we reach the ID we expect.
while (type->id.value() > expectedTypeId) {
- std::u16string typeName(u"?");
- typeName += expectedTypeId;
- mTypePool.makeRef(typeName);
+ std::stringstream typeName;
+ typeName << "?" << expectedTypeId;
+ mTypePool.makeRef(typeName.str());
expectedTypeId++;
}
expectedTypeId++;