OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * A module that contains basic utility components and methods for the | 7 * A module that contains basic utility components and methods for the |
8 * chromoting project | 8 * chromoting project |
9 * | 9 * |
10 */ | 10 */ |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 | 378 |
379 listeners.forEach( | 379 listeners.forEach( |
380 /** @param {function(*=):void} listener */ | 380 /** @param {function(*=):void} listener */ |
381 function(listener){ | 381 function(listener){ |
382 if (listener) { | 382 if (listener) { |
383 listener(opt_details); | 383 listener(opt_details); |
384 } | 384 } |
385 }); | 385 }); |
386 } | 386 } |
387 }; | 387 }; |
388 | |
389 /** | |
390 * 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.
| |
391 * @param {string} string | |
392 * @return {ArrayBuffer} | |
393 */ | |
394 base.encodeUtf8 = function(string) { | |
395 var utf8String = unescape(encodeURIComponent(string)); | |
396 var result = new Uint8Array(utf8String.length); | |
397 for (var i = 0; i < utf8String.length; i++) | |
398 result[i] = utf8String.charCodeAt(i); | |
399 return result.buffer; | |
400 } | |
401 | |
402 /** | |
403 * Decodes UTF-8 string from ArrayBuffer. | |
kelvinp
2014/08/29 01:37:09
same here
Sergey Ulanov
2014/08/29 23:40:29
Done.
| |
404 * @param {ArrayBuffer} buffer | |
405 * @return {string} | |
406 */ | |
407 base.decodeUtf8 = function(buffer) { | |
408 return decodeURIComponent( | |
409 escape(String.fromCharCode.apply(null, new Uint8Array(buffer)))); | |
410 } | |
OLD | NEW |