MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / pseudolocalize_string

Function pseudolocalize_string

tools/aapt/pseudolocalize.cpp:71–117  ·  view source on GitHub ↗

* Converts characters so they look like they've been localized. * * Note: This leaves escape sequences untouched so they can later be * processed by ResTable::collectString in the normal way. */

Source from the content-addressed store, hash-verified

69 * processed by ResTable::collectString in the normal way.
70 */
71string
72pseudolocalize_string(const string& source)
73{
74 const char* s = source.c_str();
75 string result;
76 const size_t I = source.length();
77 for (size_t i=0; i<I; i++) {
78 char c = s[i];
79 if (c == '\\') {
80 if (i<I-1) {
81 result += '\\';
82 i++;
83 c = s[i];
84 switch (c) {
85 case 'u':
86 // this one takes up 5 chars
87 result += string(s+i, 5);
88 i += 4;
89 break;
90 case 't':
91 case 'n':
92 case '#':
93 case '@':
94 case '?':
95 case '"':
96 case '\'':
97 case '\\':
98 default:
99 result += c;
100 break;
101 }
102 } else {
103 result += c;
104 }
105 } else {
106 const char* p = pseudolocalize_char(c);
107 if (p != NULL) {
108 result += p;
109 } else {
110 result += c;
111 }
112 }
113 }
114
115 //printf("result=\'%s\'\n", result.c_str());
116 return result;
117}
118
119

Callers 1

parseStyledStringFunction · 0.85

Calls 3

pseudolocalize_charFunction · 0.85
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected