Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: LayoutTests/fast/encoding/resources/char-decoding-utils.js

Issue 23532016: Handle odd data lengths in UTF-16 decoder (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Simplify Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/encoding/char-decoding-truncated-expected.txt ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/encoding/resources/char-decoding-utils.js
diff --git a/LayoutTests/fast/encoding/resources/char-decoding-utils.js b/LayoutTests/fast/encoding/resources/char-decoding-utils.js
index 07d2e608ccdcaf7623557b5b28f5fea45dc5b77b..4d5888cb7cf0574833ed9975f21ea1a460a696b8 100644
--- a/LayoutTests/fast/encoding/resources/char-decoding-utils.js
+++ b/LayoutTests/fast/encoding/resources/char-decoding-utils.js
@@ -1,14 +1,3 @@
-function hex(number)
-{
- var hexDigit = "0123456789ABCDEF";
- var hex = hexDigit.substr(number & 0xf, 1);
- while (number > 15) {
- number >>= 4;
- hex = hexDigit.substr(number & 15, 1) + hex;
- }
- return hex;
-}
-
function decodeText(charsetName, characterSequence)
{
var req = new XMLHttpRequest;
@@ -23,10 +12,10 @@ function decode(charsetName, characterSequence)
var decodedText = decodeText(charsetName, characterSequence);
var result = "";
for (var i = 0; i < decodedText.length; ++i) {
- var code = hex(decodedText.charCodeAt(i));
+ var code = decodedText.charCodeAt(i).toString(16).toUpperCase();
if (i)
result += "/";
- result += "U+" + ("0000" + code).substr(code.length, 4);
+ result += "U+" + ("0000" + code).slice(-4);
}
return result;
}
@@ -43,4 +32,3 @@ function batchTestDecode(inputData)
testDecode(inputData.encodings[i], inputData.encoded[j], inputData.unicode[j]);
}
}
-
« no previous file with comments | « LayoutTests/fast/encoding/char-decoding-truncated-expected.txt ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698