Skip to content

Commit 4297f48

Browse files
committed
Minor coding standards or small efficiencies
1 parent 31aa231 commit 4297f48

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

functions/xml/utf8_decode.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ function utf8_decode ( str_data ) {
2020
if (c1 < 128) {
2121
tmp_arr[ac++] = String.fromCharCode(c1);
2222
i++;
23-
} else if ((c1 > 191) && (c1 < 224)) {
24-
c2 = str_data.charCodeAt(i+1);
23+
}
24+
else if (c1 > 191 && c1 < 224) {
25+
c2 = str_data.charCodeAt(i + 1);
2526
tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
2627
i += 2;
27-
} else {
28-
c2 = str_data.charCodeAt(i+1);
29-
c3 = str_data.charCodeAt(i+2);
28+
}
29+
else {
30+
c2 = str_data.charCodeAt(i + 1);
31+
c3 = str_data.charCodeAt(i + 2);
3032
tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
3133
i += 3;
3234
}

functions/xml/utf8_encode.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ function utf8_encode ( argString ) {
1313

1414
var string = (argString+''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
1515

16-
var utftext = "";
17-
var start, end;
18-
var stringl = 0;
16+
var utftext = "",
17+
start, end,
18+
stringl = 0;
1919

2020
start = end = 0;
2121
stringl = string.length;
@@ -25,22 +25,24 @@ function utf8_encode ( argString ) {
2525

2626
if (c1 < 128) {
2727
end++;
28-
} else if (c1 > 127 && c1 < 2048) {
28+
}
29+
else if (c1 > 127 && c1 < 2048) {
2930
enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
30-
} else {
31+
}
32+
else {
3133
enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
3234
}
3335
if (enc !== null) {
3436
if (end > start) {
35-
utftext += string.substring(start, end);
37+
utftext += string.slice(start, end);
3638
}
3739
utftext += enc;
3840
start = end = n+1;
3941
}
4042
}
4143

4244
if (end > start) {
43-
utftext += string.substring(start, string.length);
45+
utftext += string.slice(start, stringl);
4446
}
4547

4648
return utftext;

0 commit comments

Comments
 (0)