or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-7/

Unicode Edge-Preserving Bridge

Utilities for converting between Unicode code point arrays and strings while preserving edge cases around surrogate halves and leaving provided data intact.

Capabilities

Encode code points without mutation

  • Converting code points [0x1F642, 0x61] yields the string "\u{1F642}a" and leaves the original array unchanged. @test

Decode string with lone surrogates

  • Decoding the string "\uD83Dtest" returns [0xD83D, 0x74, 0x65, 0x73, 0x74], preserving the unmatched high surrogate half. @test

Roundtrip supplementary pairs

  • Running stringToCodePoints on "hi\u{1F680}" returns [0x68, 0x69, 0x1F680], and piping that result through codePointsToString yields the original string. @test

Implementation

@generates

API

/**
 * Converts an array of Unicode code points to a string without mutating the provided array.
 * @param {number[]} codePoints
 * @returns {string}
 */
export function codePointsToString(codePoints);

/**
 * Converts a string to an array of Unicode code points, preserving unmatched surrogate halves rather than dropping them.
 * @param {string} text
 * @returns {number[]}
 */
export function stringToCodePoints(text);

Dependencies { .dependencies }

punycode { .dependency }

Provides Unicode code point conversion helpers.