summaryrefslogtreecommitdiff
path: root/test/utf.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-01-16 14:58:14 -0800
committerRuss Cox <rsc@golang.org>2009-01-16 14:58:14 -0800
commit38bb503bdb1595572fbb012cca1e531d6c780fb3 (patch)
tree321251a8cd180ad7856af54e8e531850d0735fb0 /test/utf.go
parent203878acc122be539a344540573267a7bcde29e0 (diff)
downloadgo-38bb503bdb1595572fbb012cca1e531d6c780fb3.tar.gz
casify, cleanup sys
R=r OCL=22978 CL=22984
Diffstat (limited to 'test/utf.go')
-rw-r--r--test/utf.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/test/utf.go b/test/utf.go
index 5905152b6..a93cb69db 100644
--- a/test/utf.go
+++ b/test/utf.go
@@ -6,6 +6,8 @@
package main
+import "utf8"
+
func main() {
var chars [6] int;
chars[0] = 'a';
@@ -21,7 +23,7 @@ func main() {
var l = len(s);
for w, i, j := 0,0,0; i < l; i += w {
var r int;
- r, w = sys.stringtorune(s, i);
+ r, w = utf8.DecodeRuneInString(s, i);
if w == 0 { panic("zero width in string") }
if r != chars[j] { panic("wrong value from string") }
j++;
@@ -29,7 +31,7 @@ func main() {
// encoded as bytes: 'a' 'b' 'c' e6 97 a5 e6 9c ac e8 aa 9e
const L = 12;
if L != l { panic("wrong length constructing array") }
- a := new([L]byte);
+ a := make([]byte, L);
a[0] = 'a';
a[1] = 'b';
a[2] = 'c';
@@ -44,7 +46,7 @@ func main() {
a[11] = 0x9e;
for w, i, j := 0,0,0; i < L; i += w {
var r int;
- r, w = sys.bytestorune(&a[0], i, L);
+ r, w = utf8.DecodeRune(a[i:L]);
if w == 0 { panic("zero width in bytes") }
if r != chars[j] { panic("wrong value from bytes") }
j++;