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

Unified Diff: remoting/webapp/base.js

Issue 514343002: XMPP implementation in JavaScript. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/js_proto/chrome_proto.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/base.js
diff --git a/remoting/webapp/base.js b/remoting/webapp/base.js
index c2bf1a2b54b28a67c9f7422f10887a5dae5bd2e9..17cfc2971f612f3fdb8a5b0f56090bb6e19b20f6 100644
--- a/remoting/webapp/base.js
+++ b/remoting/webapp/base.js
@@ -385,3 +385,28 @@ base.EventSource.prototype = {
});
}
};
+
+/**
+ * Converts UTF-8 string to ArrayBuffer.
+ *
+ * @param {string} string
+ * @return {ArrayBuffer}
+ */
+base.encodeUtf8 = function(string) {
+ var utf8String = unescape(encodeURIComponent(string));
+ var result = new Uint8Array(utf8String.length);
+ for (var i = 0; i < utf8String.length; i++)
+ result[i] = utf8String.charCodeAt(i);
+ return result.buffer;
+}
+
+/**
+ * Decodes UTF-8 string from ArrayBuffer.
+ *
+ * @param {ArrayBuffer} buffer
+ * @return {string}
+ */
+base.decodeUtf8 = function(buffer) {
+ return decodeURIComponent(
+ escape(String.fromCharCode.apply(null, new Uint8Array(buffer))));
+}
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/js_proto/chrome_proto.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698