types::c
types::c provides type aliases that are compatible with standard C builtin types and typedefs, as specified ISO/IEC 9899 and POSIX, as well as convenience functions for working with C types. This module is useful for C interop, for instance if an external function returns a long or a ssize, or if you need to convert between a C string and a Hare string. The types provided here shouldn't be used for most Hare code.
Some C types aren't provided by this module, since they are provided by the Hare language itself:
- _Bool, bool -> bool
- nullptr_t -> null
- (signed) int -> int
- size_t -> size
- unsigned int -> uint
- uintptr_t -> uintptr
- va_list -> valist
Some C types are mostly compatible with Hare types, with minor differences:
- C's void is an incomplete opaque type, which is also used to indicate the absence of a value. Hare provides void as a zero-size type, and opaque as an undefined-size opaque type.
- Hare doesn't have builtin imaginary or complex types, though complex types with equivalent represention to their C counterparts are declared in math::complex::. Hare doesn't allow casting between real and complex types like C does.
Hare doesn't support bit-precise integer types (_BitInt) or decimal floating point types (_Decimal32, _Decimal64, _Decimal128). Hare also doesn't provide any floating point type larger than 8 bytes, implicating `long double` on some platforms.
Additional low-level or implementation-specific types may be defined in rt::.
Index
Types
type char = schar;
type char16 = uint_least16;
type char32 = uint_least32;
type char8 = uchar;
type int_fast16 = i16;
type int_fast32 = i32;
type int_fast64 = i64;
type int_fast8 = i8;
type int_least16 = i16;
type int_least32 = i32;
type int_least64 = i64;
type int_least8 = i8;
type intmax = i64;
type intptr = i64;
type long = i64;
type longlong = i64;
type ptrdiff = i64;
type schar = i8;
type short = i16;
type sig_atomic = int;
type ssize = i64;
type uchar = u8;
type uint_fast16 = u16;
type uint_fast32 = u32;
type uint_fast64 = u64;
type uint_fast8 = u8;
type uint_least16 = u16;
type uint_least32 = u32;
type uint_least64 = u64;
type uint_least8 = u8;
type uintmax = u64;
type ulong = u64;
type ulonglong = u64;
type ushort = u16;
type wchar = i32;
type wint = u32;
Constants
def CHAR16_MAX: char16 = UINT_LEAST16_MAX;
def CHAR16_MIN: char16 = UINT_LEAST16_MIN;
def CHAR32_MAX: char32 = UINT_LEAST32_MAX;
def CHAR32_MIN: char32 = UINT_LEAST32_MIN;
def CHAR8_MAX: char8 = UCHAR_MAX;
def CHAR8_MIN: char8 = UCHAR_MIN;
def CHAR_MAX: char = SCHAR_MAX;
def CHAR_MIN: char = SCHAR_MIN;
def INTMAX_MAX: intmax = types::I64_MAX;
def INTMAX_MIN: intmax = types::I64_MIN;
def INTPTR_MAX: intptr = types::I64_MAX;
def INTPTR_MIN: intptr = types::I64_MIN;
def INT_FAST16_MAX: int_fast16 = types::I16_MAX;
def INT_FAST16_MIN: int_fast16 = types::I16_MIN;
def INT_FAST32_MAX: int_fast32 = types::I32_MAX;
def INT_FAST32_MIN: int_fast32 = types::I32_MIN;
def INT_FAST64_MAX: int_fast64 = types::I64_MAX;
def INT_FAST64_MIN: int_fast64 = types::I64_MIN;
def INT_FAST8_MAX: int_fast8 = types::I8_MAX;
def INT_FAST8_MIN: int_fast8 = types::I8_MIN;
def INT_LEAST16_MAX: int_least16 = types::I16_MAX;
def INT_LEAST16_MIN: int_least16 = types::I16_MIN;
def INT_LEAST32_MAX: int_least32 = types::I32_MAX;
def INT_LEAST32_MIN: int_least32 = types::I32_MIN;
def INT_LEAST64_MAX: int_least64 = types::I64_MAX;
def INT_LEAST64_MIN: int_least64 = types::I64_MIN;
def INT_LEAST8_MAX: int_least8 = types::I8_MAX;
def INT_LEAST8_MIN: int_least8 = types::I8_MIN;
def LLONG_MAX: longlong = types::I64_MAX;
def LLONG_MIN: longlong = types::I64_MIN;
def LONG_MAX: long = types::I64_MAX;
def LONG_MIN: long = types::I64_MIN;
def PTRDIFF_MAX: ptrdiff = types::I64_MAX;
def PTRDIFF_MIN: ptrdiff = types::I64_MIN;
def SCHAR_MAX: schar = types::I8_MAX;
def SCHAR_MIN: schar = types::I8_MIN;
def SHRT_MAX: short = types::I16_MAX;
def SHRT_MIN: short = types::I16_MIN;
def SIG_ATOMIC_MAX: sig_atomic = types::INT_MAX;
def SIG_ATOMIC_MIN: sig_atomic = types::INT_MIN;
def SSIZE_MAX: ssize = types::I64_MAX;
def SSIZE_MIN: ssize = types::I64_MIN;
def UCHAR_MAX: uchar = types::U8_MAX;
def UCHAR_MIN: uchar = types::U8_MIN;
def UINTMAX_MAX: uintmax = types::U64_MAX;
def UINTMAX_MIN: uintmax = types::U64_MIN;
def UINT_FAST16_MAX: uint_fast16 = types::U16_MAX;
def UINT_FAST16_MIN: uint_fast16 = types::U16_MIN;
def UINT_FAST32_MAX: uint_fast32 = types::U32_MAX;
def UINT_FAST32_MIN: uint_fast32 = types::U32_MIN;
def UINT_FAST64_MAX: uint_fast64 = types::U64_MAX;
def UINT_FAST64_MIN: uint_fast64 = types::U64_MIN;
def UINT_FAST8_MAX: uint_fast8 = types::U8_MAX;
def UINT_FAST8_MIN: uint_fast8 = types::U8_MIN;
def UINT_LEAST16_MAX: uint_least16 = types::U16_MAX;
def UINT_LEAST16_MIN: uint_least16 = types::U16_MIN;
def UINT_LEAST32_MAX: uint_least32 = types::U32_MAX;
def UINT_LEAST32_MIN: uint_least32 = types::U32_MIN;
def UINT_LEAST64_MAX: uint_least64 = types::U64_MAX;
def UINT_LEAST64_MIN: uint_least64 = types::U64_MIN;
def UINT_LEAST8_MAX: uint_least8 = types::U8_MAX;
def UINT_LEAST8_MIN: uint_least8 = types::U8_MIN;
def ULLONG_MAX: ulonglong = types::U64_MAX;
def ULLONG_MIN: ulonglong = types::U64_MIN;
def ULONG_MAX: ulong = types::U64_MAX;
def ULONG_MIN: ulong = types::U64_MIN;
def USHRT_MAX: ushort = types::U16_MAX;
def USHRT_MIN: ushort = types::U16_MIN;
def WCHAR_MAX: wchar = types::I32_MAX;
def WCHAR_MIN: wchar = types::I32_MIN;
def WINT_MAX: wint = types::U32_MAX;
def WINT_MIN: wint = types::U32_MIN;
Globals
let empty_string: *const char;
Functions
fn fromstr(s: const str) *char;
fn fromstr_buf(s: const str, sl: []char) *char;
fn nulstr(s: const str) *const char;
fn strlen(cstr: *const char) size;
fn strnlen(cstr: *const char, maxlen: size) size;
fn tostr(cstr: *const char) (const str | utf8::invalid);
fn tostr_unsafe(cstr: *const char) const str;
fn tostrn(cstr: *const char, length: size) (const str | utf8::invalid);
fn tostrn_unsafe(cstr: *const char, length: size) const str;
fn unterminatedstr(s: const str) *const char;
Types
type char
type char = schar;
Integer type compatible with `char`, as specified by ISO/IEC 9899.
type char16
type char16 = uint_least16;
Integer type compatible with `char16_t`, as defined in <uchar.h> and specified by ISO/IEC 9899:2011.
type char32
type char32 = uint_least32;
Integer type compatible with `char32_t`, as defined in <uchar.h> and specified by ISO/IEC 9899:2011.
type char8
type char8 = uchar;
Integer type compatible with `char8_t`, as defined in <uchar.h> and specified by ISO/IEC 9899:2023.
type int_fast16
type int_fast16 = i16;
Integer type compatible with `int_fast16_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type int_fast32
type int_fast32 = i32;
Integer type compatible with `int_fast32_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type int_fast64
type int_fast64 = i64;
Integer type compatible with `int_fast64_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type int_fast8
type int_fast8 = i8;
Integer type compatible with `int_fast8_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type int_least16
type int_least16 = i16;
Integer type compatible with `int_least16_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type int_least32
type int_least32 = i32;
Integer type compatible with `int_least32_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type int_least64
type int_least64 = i64;
Integer type compatible with `int_least64_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type int_least8
type int_least8 = i8;
Integer type compatible with `int_least8_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type intmax
type intmax = i64;
Integer type compatible with `intmax_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
Note that this type isn't necessarily the actual maximum integer type. This type should only be used when required for C interop.
type intptr
type intptr = i64;
Integer type compatible with `intptr_t`, as defined in <stdint.h> and specified by ISO/IEC 9899.
type long
type long = i64;
Integer type compatible with `signed long`, as specified by ISO/IEC 9899.
type longlong
type longlong = i64;
Integer type compatible with `signed long long`, as specified by ISO/IEC 9899:1999.
type ptrdiff
type ptrdiff = i64;
Integer type compatible with `ptrdiff_t`, as defined in <stddef.h> and specified by ISO/IEC 9899.
type schar
type schar = i8;
Integer type compatible with `signed char`, as specified by ISO/IEC 9899.
type short
type short = i16;
Integer type compatible with `signed short`, as specified by ISO/IEC 9899.
type sig_atomic
type sig_atomic = int;
Integer type compatible with 'sig_atomic_t', as defined in <signal.h> and specified by ISO/IEC 9899:1999.
type ssize
type ssize = i64;
Integer type compatible with `ssize_t`, as defined in <sys/types.h> and specified by POSIX.
type uchar
type uchar = u8;
Integer type compatible with `unsigned char`, as specified by ISO/IEC 9899.
type uint_fast16
type uint_fast16 = u16;
Integer type compatible with `uint_fast16_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type uint_fast32
type uint_fast32 = u32;
Integer type compatible with `uint_fast32_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type uint_fast64
type uint_fast64 = u64;
Integer type compatible with `uint_fast64_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type uint_fast8
type uint_fast8 = u8;
Integer type compatible with `uint_fast8_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type uint_least16
type uint_least16 = u16;
Integer type compatible with `uint_least16_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type uint_least32
type uint_least32 = u32;
Integer type compatible with `uint_least32_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type uint_least64
type uint_least64 = u64;
Integer type compatible with `uint_least64_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type uint_least8
type uint_least8 = u8;
Integer type compatible with `uint_least8_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
type uintmax
type uintmax = u64;
Integer type compatible with `uintmax_t`, as defined in <stdint.h> and specified by ISO/IEC 9899:1999.
Note that this type isn't necessarily the actual maximum integer type. This type should only be used when required for C interop.
type ulong
type ulong = u64;
Integer type compatible with `unsigned long`, as specified by ISO/IEC 9899.
type ulonglong
type ulonglong = u64;
Integer type compatible with `unsigned long long`, as specified by ISO/IEC 9899:1999.
type ushort
type ushort = u16;
Integer type compatible with `unsigned short`, as specified by ISO/IEC 9899.
type wchar
type wchar = i32;
Integer type compatible with `wchar_t`, as defined in <stddef.h> and specified by ISO/IEC 9899.
type wint
type wint = u32;
Integer type compatible with `wint_t`, as defined in <wchar.h> and specified by ISO/IEC 9899:1994.
Constants
def CHAR16_MAX
def CHAR16_MAX: char16 = UINT_LEAST16_MAX;
Maximum value which can be stored in a char16 type.
def CHAR16_MIN
def CHAR16_MIN: char16 = UINT_LEAST16_MIN;
Minimum value which can be stored in a char16 type.
def CHAR32_MAX
def CHAR32_MAX: char32 = UINT_LEAST32_MAX;
Maximum value which can be stored in a char32 type.
def CHAR32_MIN
def CHAR32_MIN: char32 = UINT_LEAST32_MIN;
Minimum value which can be stored in a char32 type.
def CHAR8_MAX
def CHAR8_MAX: char8 = UCHAR_MAX;
Maximum value which can be stored in a char8 type.
def CHAR8_MIN
def CHAR8_MIN: char8 = UCHAR_MIN;
Minimum value which can be stored in a char8 type.
def CHAR_MAX
def CHAR_MAX: char = SCHAR_MAX;
Maximum value which can be stored in a char type.
def CHAR_MIN
def CHAR_MIN: char = SCHAR_MIN;
Minimum value which can be stored in a char type.
def INTMAX_MAX
def INTMAX_MAX: intmax = types::I64_MAX;
Maximum value which can be stored in an intmax type.
def INTMAX_MIN
def INTMAX_MIN: intmax = types::I64_MIN;
Minimum value which can be stored in an intmax type.
def INTPTR_MAX
def INTPTR_MAX: intptr = types::I64_MAX;
Maximum value which can be stored in an intptr type.
def INTPTR_MIN
def INTPTR_MIN: intptr = types::I64_MIN;
Minimum value which can be stored in an intptr type.
def INT_FAST16_MAX
def INT_FAST16_MAX: int_fast16 = types::I16_MAX;
Maximum value which can be stored in an int_fast16 type.
def INT_FAST16_MIN
def INT_FAST16_MIN: int_fast16 = types::I16_MIN;
Minimum value which can be stored in an int_fast16 type.
def INT_FAST32_MAX
def INT_FAST32_MAX: int_fast32 = types::I32_MAX;
Maximum value which can be stored in an int_fast32 type.
def INT_FAST32_MIN
def INT_FAST32_MIN: int_fast32 = types::I32_MIN;
Minimum value which can be stored in an int_fast32 type.
def INT_FAST64_MAX
def INT_FAST64_MAX: int_fast64 = types::I64_MAX;
Maximum value which can be stored in an int_fast64 type.
def INT_FAST64_MIN
def INT_FAST64_MIN: int_fast64 = types::I64_MIN;
Minimum value which can be stored in an int_fast64 type.
def INT_FAST8_MAX
def INT_FAST8_MAX: int_fast8 = types::I8_MAX;
Maximum value which can be stored in an int_fast8 type.
def INT_FAST8_MIN
def INT_FAST8_MIN: int_fast8 = types::I8_MIN;
Minimum value which can be stored in an int_fast8 type.
def INT_LEAST16_MAX
def INT_LEAST16_MAX: int_least16 = types::I16_MAX;
Maximum value which can be stored in an int_least16 type.
def INT_LEAST16_MIN
def INT_LEAST16_MIN: int_least16 = types::I16_MIN;
Minimum value which can be stored in an int_least16 type.
def INT_LEAST32_MAX
def INT_LEAST32_MAX: int_least32 = types::I32_MAX;
Maximum value which can be stored in an int_least32 type.
def INT_LEAST32_MIN
def INT_LEAST32_MIN: int_least32 = types::I32_MIN;
Minimum value which can be stored in an int_least32 type.
def INT_LEAST64_MAX
def INT_LEAST64_MAX: int_least64 = types::I64_MAX;
Maximum value which can be stored in an int_least64 type.
def INT_LEAST64_MIN
def INT_LEAST64_MIN: int_least64 = types::I64_MIN;
Minimum value which can be stored in an int_least64 type.
def INT_LEAST8_MAX
def INT_LEAST8_MAX: int_least8 = types::I8_MAX;
Maximum value which can be stored in an int_least8 type.
def INT_LEAST8_MIN
def INT_LEAST8_MIN: int_least8 = types::I8_MIN;
Minimum value which can be stored in an int_least8 type.
def LLONG_MAX
def LLONG_MAX: longlong = types::I64_MAX;
Maximum value which can be stored in a longlong type.
def LLONG_MIN
def LLONG_MIN: longlong = types::I64_MIN;
Minimum value which can be stored in a longlong type.
def LONG_MAX
def LONG_MAX: long = types::I64_MAX;
Maximum value which can be stored in a long type.
def LONG_MIN
def LONG_MIN: long = types::I64_MIN;
Minimum value which can be stored in a long type.
def PTRDIFF_MAX
def PTRDIFF_MAX: ptrdiff = types::I64_MAX;
Maximum value which can be stored in a ptrdiff type.
def PTRDIFF_MIN
def PTRDIFF_MIN: ptrdiff = types::I64_MIN;
Minimum value which can be stored in a ptrdiff type.
def SCHAR_MAX
def SCHAR_MAX: schar = types::I8_MAX;
Maximum value which can be stored in an schar type.
def SCHAR_MIN
def SCHAR_MIN: schar = types::I8_MIN;
Minimum value which can be stored in an schar type.
def SHRT_MAX
def SHRT_MAX: short = types::I16_MAX;
Maximum value which can be stored in a short type.
def SHRT_MIN
def SHRT_MIN: short = types::I16_MIN;
Minimum value which can be stored in a short type.
def SIG_ATOMIC_MAX
def SIG_ATOMIC_MAX: sig_atomic = types::INT_MAX;
Maximum value which can be stored in a sig_atomic type.
def SIG_ATOMIC_MIN
def SIG_ATOMIC_MIN: sig_atomic = types::INT_MIN;
Minimum value which can be stored in a sig_atomic type.
def SSIZE_MAX
def SSIZE_MAX: ssize = types::I64_MAX;
Maximum value which can be stored in an ssize type.
def SSIZE_MIN
def SSIZE_MIN: ssize = types::I64_MIN;
Minimum value which can be stored in an ssize type.
def UCHAR_MAX
def UCHAR_MAX: uchar = types::U8_MAX;
Maximum value which can be stored in a uchar type.
def UCHAR_MIN
def UCHAR_MIN: uchar = types::U8_MIN;
Minimum value which can be stored in a uchar type.
def UINTMAX_MAX
def UINTMAX_MAX: uintmax = types::U64_MAX;
Maximum value which can be stored in a uintmax type.
def UINTMAX_MIN
def UINTMAX_MIN: uintmax = types::U64_MIN;
Minimum value which can be stored in a uintmax type.
def UINT_FAST16_MAX
def UINT_FAST16_MAX: uint_fast16 = types::U16_MAX;
Maximum value which can be stored in a uint_fast16 type.
def UINT_FAST16_MIN
def UINT_FAST16_MIN: uint_fast16 = types::U16_MIN;
Minimum value which can be stored in a uint_fast16 type.
def UINT_FAST32_MAX
def UINT_FAST32_MAX: uint_fast32 = types::U32_MAX;
Maximum value which can be stored in a uint_fast32 type.
def UINT_FAST32_MIN
def UINT_FAST32_MIN: uint_fast32 = types::U32_MIN;
Minimum value which can be stored in a uint_fast32 type.
def UINT_FAST64_MAX
def UINT_FAST64_MAX: uint_fast64 = types::U64_MAX;
Maximum value which can be stored in a uint_fast64 type.
def UINT_FAST64_MIN
def UINT_FAST64_MIN: uint_fast64 = types::U64_MIN;
Minimum value which can be stored in a uint_fast64 type.
def UINT_FAST8_MAX
def UINT_FAST8_MAX: uint_fast8 = types::U8_MAX;
Maximum value which can be stored in a uint_fast8 type.
def UINT_FAST8_MIN
def UINT_FAST8_MIN: uint_fast8 = types::U8_MIN;
Minimum value which can be stored in a uint_fast8 type.
def UINT_LEAST16_MAX
def UINT_LEAST16_MAX: uint_least16 = types::U16_MAX;
Maximum value which can be stored in a uint_least16 type.
def UINT_LEAST16_MIN
def UINT_LEAST16_MIN: uint_least16 = types::U16_MIN;
Minimum value which can be stored in a uint_least16 type.
def UINT_LEAST32_MAX
def UINT_LEAST32_MAX: uint_least32 = types::U32_MAX;
Maximum value which can be stored in a uint_least32 type.
def UINT_LEAST32_MIN
def UINT_LEAST32_MIN: uint_least32 = types::U32_MIN;
Minimum value which can be stored in a uint_least32 type.
def UINT_LEAST64_MAX
def UINT_LEAST64_MAX: uint_least64 = types::U64_MAX;
Maximum value which can be stored in a uint_least64 type.
def UINT_LEAST64_MIN
def UINT_LEAST64_MIN: uint_least64 = types::U64_MIN;
Minimum value which can be stored in a uint_least64 type.
def UINT_LEAST8_MAX
def UINT_LEAST8_MAX: uint_least8 = types::U8_MAX;
Maximum value which can be stored in a uint_least8 type.
def UINT_LEAST8_MIN
def UINT_LEAST8_MIN: uint_least8 = types::U8_MIN;
Minimum value which can be stored in a uint_least8 type.
def ULLONG_MAX
def ULLONG_MAX: ulonglong = types::U64_MAX;
Maximum value which can be stored in a ulonglong type.
def ULLONG_MIN
def ULLONG_MIN: ulonglong = types::U64_MIN;
Minimum value which can be stored in a ulonglong type.
def ULONG_MAX
def ULONG_MAX: ulong = types::U64_MAX;
Maximum value which can be stored in a ulong type.
def ULONG_MIN
def ULONG_MIN: ulong = types::U64_MIN;
Minimum value which can be stored in a ulong type.
def USHRT_MAX
def USHRT_MAX: ushort = types::U16_MAX;
Maximum value which can be stored in a ushort type.
def USHRT_MIN
def USHRT_MIN: ushort = types::U16_MIN;
Minimum value which can be stored in a ushort type.
def WCHAR_MAX
def WCHAR_MAX: wchar = types::I32_MAX;
Maximum value which can be stored in a wchar type.
def WCHAR_MIN
def WCHAR_MIN: wchar = types::I32_MIN;
Minimum value which can be stored in a wchar type.
def WINT_MAX
def WINT_MAX: wint = types::U32_MAX;
Maximum value which can be stored in a wint type.
def WINT_MIN
def WINT_MIN: wint = types::U32_MIN;
Minimum value which can be stored in a wint type.
Globals
let empty_string
let empty_string: *const char;
An empty NUL-terminated C string.
Functions
fn fromstr
fn fromstr(s: const str) *char;
Converts a Hare string to a C string. The result is allocated; the caller must free it when they're done.
fn fromstr_buf
fn fromstr_buf(s: const str, sl: []char) *char;
Converts a Hare string to a C string. The result is stored into a user-supplied buffer.
fn nulstr
fn nulstr(s: const str) *const char;
Converts a NUL-terminated Hare string to a C string. Aborts if the input string isn't NUL-terminated. The result is borrowed from the input.
fn strlen
fn strlen(cstr: *const char) size;
Computes the length of a NUL-terminated C string, in octets, in O(n). The computed length does not include the NUL terminator.
fn strnlen
fn strnlen(cstr: *const char, maxlen: size) size;
Computes the length of a NUL-terminated C string, only looking at the first maxlen bytes. The computed length does not include the NUL terminator.
fn tostr
fn tostr(cstr: *const char) (const str | utf8::invalid);
Converts a C string to a Hare string in O(n). If the string is not valid UTF-8, return encoding::utf8::invalid.
fn tostr_unsafe
fn tostr_unsafe(cstr: *const char) const str;
Converts a C string to a Hare string in O(n), and does not check if it's valid UTF-8.
fn tostrn
fn tostrn(cstr: *const char, length: size) (const str | utf8::invalid);
Converts a C string with a given length to a Hare string. If the string is not valid UTF-8, return encoding::utf8::invalid.
fn tostrn_unsafe
fn tostrn_unsafe(cstr: *const char, length: size) const str;
Converts a C string with a given length to a Hare string, and does not check if it's valid UTF-8.
fn unterminatedstr
fn unterminatedstr(s: const str) *const char;
Converts a non-NUL-terminated Hare string to a *const char. The return value is borrowed from the input, except in the case of an empty string, in which case it is statically allocated.
Use with caution!