mirror of
https://github.com/revanced/smali.git
synced 2025-05-29 12:20:11 +02:00
changed the logic that generates escaped strings to always use the /uxxxx format, instead of the 3 digital octal escape
git-svn-id: https://smali.googlecode.com/svn/trunk@177 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
78314beef2
commit
4ec387882d
@ -165,49 +165,26 @@ public final class Utf8Utils {
|
|||||||
|
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
char c = value.charAt(i);
|
char c = value.charAt(i);
|
||||||
|
|
||||||
if ((c >= ' ') && (c < 0x7f)) {
|
if ((c >= ' ') && (c < 0x7f)) {
|
||||||
if ((c == '\'') || (c == '\"') || (c == '\\')) {
|
if ((c == '\'') || (c == '\"') || (c == '\\')) {
|
||||||
sb.append('\\');
|
sb.append('\\');
|
||||||
}
|
}
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
|
continue;
|
||||||
} else if (c <= 0x7f) {
|
} else if (c <= 0x7f) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\n': sb.append("\\n"); break;
|
case '\n': sb.append("\\n"); continue;
|
||||||
case '\r': sb.append("\\r"); break;
|
case '\r': sb.append("\\r"); continue;
|
||||||
case '\t': sb.append("\\t"); break;
|
case '\t': sb.append("\\t"); continue;
|
||||||
default: {
|
|
||||||
/*
|
|
||||||
* Represent the character as an octal escape.
|
|
||||||
* If the next character is a valid octal
|
|
||||||
* digit, disambiguate by using the
|
|
||||||
* three-digit form.
|
|
||||||
*/
|
|
||||||
char nextChar =
|
|
||||||
(i < (len - 1)) ? value.charAt(i + 1) : 0;
|
|
||||||
boolean displayZero =
|
|
||||||
(nextChar >= '0') && (nextChar <= '7');
|
|
||||||
sb.append('\\');
|
|
||||||
for (int shift = 6; shift >= 0; shift -= 3) {
|
|
||||||
char outChar = (char) (((c >> shift) & 7) + '0');
|
|
||||||
if ((outChar != '0') || displayZero) {
|
|
||||||
sb.append(outChar);
|
|
||||||
displayZero = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (! displayZero) {
|
|
||||||
// Ironic edge case: The original value was 0.
|
|
||||||
sb.append('0');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
sb.append("\\u");
|
|
||||||
sb.append(Character.forDigit(c >> 12, 16));
|
|
||||||
sb.append(Character.forDigit((c >> 8) & 0x0f, 16));
|
|
||||||
sb.append(Character.forDigit((c >> 4) & 0x0f, 16));
|
|
||||||
sb.append(Character.forDigit(c & 0x0f, 16));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sb.append("\\u");
|
||||||
|
sb.append(Character.forDigit(c >> 12, 16));
|
||||||
|
sb.append(Character.forDigit((c >> 8) & 0x0f, 16));
|
||||||
|
sb.append(Character.forDigit((c >> 4) & 0x0f, 16));
|
||||||
|
sb.append(Character.forDigit(c & 0x0f, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user