summaryrefslogtreecommitdiff
path: root/test/encodechar.myr
blob: eb32e184f55458595b70dbe327a56318892ce63c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* 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)
			std.write(1, "couldn't encode\n")
		;;
		std.write(1, buf[:std.charlen(c)])
	;;
}