gleam-lang / gleam-lang/stdlib

Suggestion: Add `bit_array.to_lossy_string()` or similar

Open
#797 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Gleam
Stars
710
Forks
225
Avg merge
5h 52m
Merged PRs (30d)
3

Description

There is currently no way to (easily) convert from a BitArray that contains non-UTF codepoints to a String.
This is usable when, for example, you need to handle filepaths and you're not concerned with the exact naming but want a best-effort conversion.

In Rust there's `OsStr` and `Path`-derivations for this. One first step could be to implement something like [Rust's `to_string_lossy`](https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.to_string_lossy)

```gleam
fn to_lossy_string(bytes: BitArray) -> String {
todo
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.