Skip to content

from_char_code builtin #210

Description

@aallan

Add a from_char_code builtin that is the inverse of the existing char_code function.

Proposed function

  • from_char_code(@Nat -> @String) -- create a single-character string from an ASCII/Unicode code point

Rationale

char_code(@String, @Int -> @Nat) exists but there is no way to go from a code point back to a string. Without this, strings cannot be constructed character by character, which is needed for any algorithmic string building (encoding, formatting, character-level transformations).

Implementation notes

Trivial: allocate 1-byte string via $alloc, store the byte value, return (ptr, 1). Should validate that the value is in valid range (0-127 for ASCII, or 0-255 for extended).

Dependencies

  • None

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenCode generation backendenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions