Skip to content

Commit

Permalink
Construct ASCII text from bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Oct 30, 2024
1 parent 30ff8f7 commit df9e5f2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/gossamer-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit df9e5f2

Please sign in to comment.