Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions stringview.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ if (!Number.isInteger) {

/*\
|*|
|*| StringView - Mozilla Developer Network - revision #6
|*| StringView - Mozilla Developer Network
|*|
|*| Revision #8, October 6, 2014
|*|
|*| https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays/StringView
|*| https://developer.mozilla.org/User:fusionchess
|*| https://developer.mozilla.org/en-US/docs/User:fusionchess
|*|
|*| This framework is released under the GNU Public License, version 3 or later.
|*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
|*| This framework is released under the GNU Lesser General Public License, version 3 or later.
|*| http://www.gnu.org/licenses/lgpl-3.0.html
|*|
\*/

Expand Down Expand Up @@ -320,7 +322,7 @@ StringView.loadUTF8CharCode = function (aChars, nIdx) {
var nLen = aChars.length, nPart = aChars[nIdx];

return nPart > 251 && nPart < 254 && nIdx + 5 < nLen ?
/* (nPart - 252 << 32) is not possible in ECMAScript! So...: */
/* (nPart - 252 << 30) may be not safe in ECMAScript! So...: */
/* six bytes */ (nPart - 252) * 1073741824 + (aChars[nIdx + 1] - 128 << 24) + (aChars[nIdx + 2] - 128 << 18) + (aChars[nIdx + 3] - 128 << 12) + (aChars[nIdx + 4] - 128 << 6) + aChars[nIdx + 5] - 128
: nPart > 247 && nPart < 252 && nIdx + 4 < nLen ?
/* five bytes */ (nPart - 248 << 24) + (aChars[nIdx + 1] - 128 << 18) + (aChars[nIdx + 2] - 128 << 12) + (aChars[nIdx + 3] - 128 << 6) + aChars[nIdx + 4] - 128
Expand Down Expand Up @@ -366,7 +368,7 @@ StringView.putUTF8CharCode = function (aTarget, nChar, nPutAt) {
aTarget[nIdx++] = 0x80 /* 128 */ + (nChar & 0x3f /* 63 */);
} else /* if (nChar <= 0x7fffffff) */ { /* 2147483647 */
/* six bytes */
aTarget[nIdx++] = 0xfc /* 252 */ + /* (nChar >>> 32) is not possible in ECMAScript! So...: */ (nChar / 1073741824);
aTarget[nIdx++] = 0xfc /* 252 */ + /* (nChar >>> 30) may be not safe in ECMAScript! So...: */ (nChar / 1073741824);
aTarget[nIdx++] = 0x80 /* 128 */ + ((nChar >>> 24) & 0x3f /* 63 */);
aTarget[nIdx++] = 0x80 /* 128 */ + ((nChar >>> 18) & 0x3f /* 63 */);
aTarget[nIdx++] = 0x80 /* 128 */ + ((nChar >>> 12) & 0x3f /* 63 */);
Expand Down Expand Up @@ -666,4 +668,4 @@ StringView.prototype.valueOf = StringView.prototype.toString = function () {

return sView;

};
};