|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
698 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var GetIntrinsic = require('get-intrinsic');
|
|---|
| 4 |
|
|---|
| 5 | var $TypeError = require('es-errors/type');
|
|---|
| 6 | var $fromCharCode = GetIntrinsic('%String.fromCharCode%');
|
|---|
| 7 |
|
|---|
| 8 | var floor = require('./floor');
|
|---|
| 9 | var modulo = require('./modulo');
|
|---|
| 10 |
|
|---|
| 11 | var isCodePoint = require('../helpers/isCodePoint');
|
|---|
| 12 |
|
|---|
| 13 | // https://262.ecma-international.org/7.0/#sec-utf16encoding
|
|---|
| 14 |
|
|---|
| 15 | module.exports = function UTF16Encoding(cp) {
|
|---|
| 16 | if (!isCodePoint(cp)) {
|
|---|
| 17 | throw new $TypeError('Assertion failed: `cp` must be >= 0 and <= 0x10FFFF');
|
|---|
| 18 | }
|
|---|
| 19 | if (cp <= 65535) {
|
|---|
| 20 | return $fromCharCode(cp);
|
|---|
| 21 | }
|
|---|
| 22 | var cu1 = $fromCharCode(floor((cp - 65536) / 1024) + 0xD800);
|
|---|
| 23 | var cu2 = $fromCharCode(modulo(cp - 65536, 1024) + 0xDC00);
|
|---|
| 24 | return cu1 + cu2;
|
|---|
| 25 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.