Loading tools/aapt/pseudolocalize.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -360,9 +360,15 @@ String16 PseudoMethodBidi::text(const String16& source) String16 result; bool lastspace = true; bool space = true; bool escape = false; const char16_t ESCAPE_CHAR = '\\'; for (size_t i=0; i<source.size(); i++) { char16_t c = s[i]; space = is_space(c); if (!escape && c == ESCAPE_CHAR) { escape = true; continue; } space = (!escape && is_space(c)) || (escape && (c == 'n' || c == 't')); if (lastspace && !space) { // Word start result += k_rlm + k_rlo; Loading @@ -371,6 +377,10 @@ String16 PseudoMethodBidi::text(const String16& source) result += k_pdf + k_rlm; } lastspace = space; if (escape) { result.append(&ESCAPE_CHAR, 1); escape=false; } result.append(&c, 1); } if (!lastspace) { Loading tools/aapt/tests/Pseudolocales_test.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,10 @@ TEST(Pseudolocales, PlaintextBidi) { "\xe2\x80\x8f\xE2\x80\xaehello\xE2\x80\xac\xe2\x80\x8f\n" \ " \xe2\x80\x8f\xE2\x80\xaeworld\xE2\x80\xac\xe2\x80\x8f\n", PSEUDO_BIDI); simple_helper("hello\\nworld\\n", "\xe2\x80\x8f\xE2\x80\xaehello\xE2\x80\xac\xe2\x80\x8f\\n" "\xe2\x80\x8f\xE2\x80\xaeworld\xE2\x80\xac\xe2\x80\x8f\\n", PSEUDO_BIDI); } TEST(Pseudolocales, SimpleICU) { Loading tools/aapt2/compile/Pseudolocalizer.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -445,9 +445,15 @@ std::string PseudoMethodBidi::Text(const StringPiece& source) { std::string result; bool lastspace = true; bool space = true; bool escape = false; const char ESCAPE_CHAR = '\\'; for (size_t i = 0; i < source.size(); i++) { char c = s[i]; space = isspace(c); if (!escape && c == ESCAPE_CHAR) { escape = true; continue; } space = (!escape && isspace(c)) || (escape && (c == 'n' || c == 't')); if (lastspace && !space) { // Word start result += kRlm + kRlo; Loading @@ -456,6 +462,10 @@ std::string PseudoMethodBidi::Text(const StringPiece& source) { result += kPdf + kRlm; } lastspace = space; if (escape) { result.append(&ESCAPE_CHAR, 1); escape=false; } result.append(&c, 1); } if (!lastspace) { Loading tools/aapt2/compile/Pseudolocalizer_test.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,11 @@ TEST(PseudolocalizerTest, PlaintextBidi) { "\xe2\x80\x8f\xE2\x80\xaehello\xE2\x80\xac\xe2\x80\x8f\n" " \xe2\x80\x8f\xE2\x80\xaeworld\xE2\x80\xac\xe2\x80\x8f\n", Pseudolocalizer::Method::kBidi)); EXPECT_TRUE( SimpleHelper("hello\\nworld\\n", "\xe2\x80\x8f\xE2\x80\xaehello\xE2\x80\xac\xe2\x80\x8f\\n" "\xe2\x80\x8f\xE2\x80\xaeworld\xE2\x80\xac\xe2\x80\x8f\\n", Pseudolocalizer::Method::kBidi)); } TEST(PseudolocalizerTest, SimpleICU) { Loading Loading
tools/aapt/pseudolocalize.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -360,9 +360,15 @@ String16 PseudoMethodBidi::text(const String16& source) String16 result; bool lastspace = true; bool space = true; bool escape = false; const char16_t ESCAPE_CHAR = '\\'; for (size_t i=0; i<source.size(); i++) { char16_t c = s[i]; space = is_space(c); if (!escape && c == ESCAPE_CHAR) { escape = true; continue; } space = (!escape && is_space(c)) || (escape && (c == 'n' || c == 't')); if (lastspace && !space) { // Word start result += k_rlm + k_rlo; Loading @@ -371,6 +377,10 @@ String16 PseudoMethodBidi::text(const String16& source) result += k_pdf + k_rlm; } lastspace = space; if (escape) { result.append(&ESCAPE_CHAR, 1); escape=false; } result.append(&c, 1); } if (!lastspace) { Loading
tools/aapt/tests/Pseudolocales_test.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,10 @@ TEST(Pseudolocales, PlaintextBidi) { "\xe2\x80\x8f\xE2\x80\xaehello\xE2\x80\xac\xe2\x80\x8f\n" \ " \xe2\x80\x8f\xE2\x80\xaeworld\xE2\x80\xac\xe2\x80\x8f\n", PSEUDO_BIDI); simple_helper("hello\\nworld\\n", "\xe2\x80\x8f\xE2\x80\xaehello\xE2\x80\xac\xe2\x80\x8f\\n" "\xe2\x80\x8f\xE2\x80\xaeworld\xE2\x80\xac\xe2\x80\x8f\\n", PSEUDO_BIDI); } TEST(Pseudolocales, SimpleICU) { Loading
tools/aapt2/compile/Pseudolocalizer.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -445,9 +445,15 @@ std::string PseudoMethodBidi::Text(const StringPiece& source) { std::string result; bool lastspace = true; bool space = true; bool escape = false; const char ESCAPE_CHAR = '\\'; for (size_t i = 0; i < source.size(); i++) { char c = s[i]; space = isspace(c); if (!escape && c == ESCAPE_CHAR) { escape = true; continue; } space = (!escape && isspace(c)) || (escape && (c == 'n' || c == 't')); if (lastspace && !space) { // Word start result += kRlm + kRlo; Loading @@ -456,6 +462,10 @@ std::string PseudoMethodBidi::Text(const StringPiece& source) { result += kPdf + kRlm; } lastspace = space; if (escape) { result.append(&ESCAPE_CHAR, 1); escape=false; } result.append(&c, 1); } if (!lastspace) { Loading
tools/aapt2/compile/Pseudolocalizer_test.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,11 @@ TEST(PseudolocalizerTest, PlaintextBidi) { "\xe2\x80\x8f\xE2\x80\xaehello\xE2\x80\xac\xe2\x80\x8f\n" " \xe2\x80\x8f\xE2\x80\xaeworld\xE2\x80\xac\xe2\x80\x8f\n", Pseudolocalizer::Method::kBidi)); EXPECT_TRUE( SimpleHelper("hello\\nworld\\n", "\xe2\x80\x8f\xE2\x80\xaehello\xE2\x80\xac\xe2\x80\x8f\\n" "\xe2\x80\x8f\xE2\x80\xaeworld\xE2\x80\xac\xe2\x80\x8f\\n", Pseudolocalizer::Method::kBidi)); } TEST(PseudolocalizerTest, SimpleICU) { Loading