From df9e5f2969972ae73ae970da3edf763a8ddbfd20 Mon Sep 17 00:00:00 2001 From: Jon Pretty Date: Wed, 30 Oct 2024 15:06:04 +0100 Subject: [PATCH] Construct ASCII text from bytes --- src/core/gossamer-core.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/gossamer-core.scala b/src/core/gossamer-core.scala index 99a0e27..b785546 100644 --- a/src/core/gossamer-core.scala +++ b/src/core/gossamer-core.scala @@ -53,6 +53,8 @@ extension (textObject: Text.type) block(using buffer) buffer() + def ascii(bytes: Bytes): Text = new String(bytes.mutable(using Unsafe), "ASCII").tt + def fill(length: Int)(lambda: Int => Char): Text = val array = new Array[Char](length) (0 until length).each { index => array(index) = lambda(index) }