deimos-lang/dm_lib_sketching/std/core/string.dm
2024-12-31 12:07:48 -06:00

32 lines
665 B
Plaintext

ns std::core
use std::text::Encoding
pub int String : Display {
bytes: Array<Byte>
characters: Array<Character>
encoding: Encoding
length: Int
impl fn to_string() = self
}
impl StringImpl(bytes: Array<Byte>, /* encoding: Encoding */) {
length = bytes.length
characters = lazy {
todo('parse the utf8 bytes and return an Array<Character>')
}
}
pub mod string {
// Example usage:
// let bytes = array::of(0x64, 0x65, 0x69, 0x6d, 0x6f, 0x73)
// let s = string::from_utf8_bytes(bytes)
// println s // "deimos"
fn from_utf8_bytes(bytes: Array<Byte>): String = StringImpl(bytes, /* Encoding::Utf8 */)
}