import "std/io";

extern str_len(s: &const string) -> uint64;
/// Converts a string to an array of bytes (uint8) using UTF-8 encoding
extern to_bytes(s: &const string) -> [uint8];

struct String {
private:
    s: [uint8];
    String(input: [uint8]) {
        this.s = input;
    }
public:
    /// Creates a String from any string literal UTF-8 encoded
    fun from_str(s: &const string) -> String {
        let bytes = to_bytes(s);
        return new String(bytes);
    }
}

fun main() {
    let str = String::from_str("Hello, Atlas!");
    print("Original string: ");
    println(str.s);
    //Let's do a test with some UTF-8 characters
    let utf8_str = String::from_str("Hello, 世界!");
    print("UTF-8 string bytes: ");
    println(utf8_str.s);
}
