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

Unified Diff: sky/framework/xmlhttprequest.sky

Issue 806043002: Use existing unicode.sky instead of re-inventing (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/xmlhttprequest.sky
diff --git a/sky/framework/xmlhttprequest.sky b/sky/framework/xmlhttprequest.sky
index ce68eafd94a86cf96ea7190e6ac8e582f216e3f6..2fe19e73b9197b8b387a97a2a4a7a6175a028c2d 100644
--- a/sky/framework/xmlhttprequest.sky
+++ b/sky/framework/xmlhttprequest.sky
@@ -21,17 +21,6 @@ class Private {
}
}
-// Somewhat hacky, but works.
-function stringToUTF8Buffer(string) {
- var string = unescape(encodeURIComponent(string));
- var charList = string.split('');
- var uintArray = [];
- for (var i = 0; i < charList.length; i++) {
- uintArray.push(charList[i].charCodeAt(0));
- }
- return new Uint8Array(uintArray);
-}
-
// https://xhr.spec.whatwg.org
class XMLHttpRequest {
constructor() {
@@ -89,7 +78,8 @@ class XMLHttpRequest {
var bodyAsBufferView = null;
if (typeof(body) === "string") {
this.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
- bodyAsBufferView = stringToUTF8Buffer(body);
+ var bodyAsBufferView = new Uint8Array(unicode.utf8Length(body));
+ unicode.encodeUtf8String(body, bodyAsBufferView);
} else {
bodyAsBufferView = new Uint8Array(body);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698