Chromium Code Reviews| Index: remoting/webapp/base.js |
| diff --git a/remoting/webapp/base.js b/remoting/webapp/base.js |
| index c2bf1a2b54b28a67c9f7422f10887a5dae5bd2e9..3041616642271e38d5d3578561aa65c3c7d488f8 100644 |
| --- a/remoting/webapp/base.js |
| +++ b/remoting/webapp/base.js |
| @@ -385,3 +385,26 @@ base.EventSource.prototype = { |
| }); |
| } |
| }; |
| + |
| +/** |
| + * Converts UTF-8 string to ArrayBuffer. |
|
kelvinp
2014/08/29 01:37:09
Nit: blank line between JSDocs and params annotati
Sergey Ulanov
2014/08/29 23:40:29
Done.
|
| + * @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. |
|
kelvinp
2014/08/29 01:37:09
same here
Sergey Ulanov
2014/08/29 23:40:29
Done.
|
| + * @param {ArrayBuffer} buffer |
| + * @return {string} |
| + */ |
| +base.decodeUtf8 = function(buffer) { |
| + return decodeURIComponent( |
| + escape(String.fromCharCode.apply(null, new Uint8Array(buffer)))); |
| +} |