Skip to content

[Clarity-4] to-ascii? #6397

@obycode

Description

@obycode

Conversion to string-ascii: to-ascii?

Originally proposed here.

to-ascii? is a new Clarity function that converts simple values into their
string-ascii representations.

  • Input: int | uint | bool | principal | (buff 524284) |
    (string-utf8 1048571)
  • Output: (response (string-ascii 1048571) uint)
  • Signature: (to-ascii? value)
  • Description: Returns the string-ascii representation of the input value
    in an ok response on success. The only error condition is if the input type
    is string-utf8 and the value contains non-ASCII characters, in which case,
    (err u1) is returned.
  • Example:
    (to-ascii? true) ;; Returns (ok "true")
    (to-ascii? 42) ;; Returns (ok "42")
    (to-ascii? 'SP2QEZ06AGJ3RKJPBV14SY1V5BBFNAW33D96YPGZF) ;; Returns (ok "SP2QEZ06AGJ3RKJPBV14SY1V5BBFNAW33D96YPGZF")
    (to-ascii? 0x12345678) ;; Returns (ok "0x12345678")

See SIP proposal

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Status: ✅ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions