summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceUtils.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2019-03-11 11:00:25 -0700
committerRyan Mitchell <rtmitchell@google.com>2019-03-11 11:00:25 -0700
commit0f3267590980bccd39f2d954320aa97cf1901c0b (patch)
tree2c265050794cdf04c8d3c7aa0d7c0b259a47958e /tools/aapt2/ResourceUtils.cpp
parent41469c3b522f28c4590398ad6e35193b2142dda7 (diff)
Do not convert whitespace chars above max char to regular space
Using isspace and iswspace on characters above the maximum char value is undefined. This change makes aapt2 use isspace like aapt and only trims whitespace characters at or below the maximum char value like aapt2. Bug: 121017795 Test: aapt2_tests Change-Id: I015e4b77f0ff53e409e880fcf9ae104ba3444d1a
Diffstat (limited to 'tools/aapt2/ResourceUtils.cpp')
-rw-r--r--tools/aapt2/ResourceUtils.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp
index f0e4d9e7ce8c..a571aee61546 100644
--- a/tools/aapt2/ResourceUtils.cpp
+++ b/tools/aapt2/ResourceUtils.cpp
@@ -40,8 +40,6 @@ using ::android::base::StringPrintf;
namespace aapt {
namespace ResourceUtils {
-constexpr int32_t kNonBreakingSpace = 0xa0;
-
Maybe<ResourceName> ToResourceName(
const android::ResTable::resource_name& name_in) {
// TODO: Remove this when ResTable and AssetManager(1) are removed from AAPT2
@@ -854,7 +852,8 @@ StringBuilder& StringBuilder::AppendText(const std::string& text) {
Utf8Iterator iter(text);
while (iter.HasNext()) {
char32_t codepoint = iter.Next();
- if (!preserve_spaces_ && !quote_ && codepoint != kNonBreakingSpace && iswspace(codepoint)) {
+ if (!preserve_spaces_ && !quote_ && (codepoint <= std::numeric_limits<char>::max())
+ && isspace(static_cast<char>(codepoint))) {
if (!last_codepoint_was_space_) {
// Emit a space if it's the first.
xml_string_.text += ' ';