shithub: mc

ref: 58ace77cc4b17d32fe0cf3904ffd57b4b1afe4b4
dir: /test/encodechar.myr/

View raw version
/* checks that we can decode and encode characters from a utf8 string. */
use std

const main = {args : byte[:][:]
	chartypes()
}

const chartypes = {
	var s
	var c
	var foo
	var buf : byte[32]

	s = "1世界äa\n"
	while s.len != 0
		(c, s) = std.striter(s)
		foo = c
		if std.encode(buf[:std.charlen(c)], c) == 0
			std.write(1, "couldn't encode\n")
		;;
		std.write(1, buf[:std.charlen(c)])
	;;
}