JS: String.fromCodePoint

By Xah Lee. Date: . Last updated: .

New in ES2015.

String.fromCodePoint ( codepoint1, codepoint2 … )

Return a string, each character corresponds to the codepoint in argument.

[see JS: Character, Code Unit, Codepoint]

// create string from unicode codepoints

console.log (
 String.fromCodePoint ( 97, 128514 ) === "a😂"
);

// 97 is the codepoint for letter “a”
// 128514 is the codepoint for the char 😂 FACE WITH TEARS OF JOY

How to Find Character's Codepoint

JS: String.prototype.codePointAt

For codepoint of English character and punctuations, see ASCII Table.

fromCodePoint polyfill

if (!String.fromCodePoint) {
// ES6 Unicode Shims 0.1 , © 2012 Steven Levithan http://slevithan.com/ , MIT License
    String.fromCodePoint = function fromCodePoint () {
        var chars = [], point, offset, units, i
        for (i = 0; i < arguments.length; ++i) {
            point = arguments[i]
            offset = point - 0x10000
            units = point > 0xFFFF ? [0xD800 + (offset >> 10), 0xDC00 + (offset & 0x3FF)] : [point]
            chars.push(String.fromCharCode.apply(null, units))
        }
        return chars.join("")
    }
}

JS Character

  1. Character, Code Unit, Codepoint
  2. Character To/From Codepoint
  3. String.fromCodePoint
  4. String.fromCharCode
  5. String.prototype.charAt
  6. String.prototype.charCodeAt
  7. String.prototype.codePointAt
  8. Convert Decimal/Hex
  9. Unicode Escape Sequence

JS String

  1. String Overview
  2. Template String ⭐
  3. Char, Code Unit, Codepoint
  4. String Escape Sequence
  5. Unicode Escape Sequence

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Object Ref
  5. DOM Scripting
  6. SVG
  7. Blog