3 // Copyright 2022 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Examples from the language spec section on string conversions.
13 _ = string('a') // "a"
14 _ = string(-1) // "\ufffd" == "\xef\xbf\xbd"
15 _ = string(0xf8) // "\u00f8" == "ø" == "\xc3\xb8"
18 _ = myString(0x65e5) // "\u65e5" == "日" == "\xe6\x97\xa5"
21 _ = string([]byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}) // "hellø"
22 _ = string([]byte{}) // ""
23 _ = string([]byte(nil)) // ""
26 _ = string(bytes{'h', 'e', 'l', 'l', '\xc3', '\xb8'}) // "hellø"
29 _ = string([]myByte{'w', 'o', 'r', 'l', 'd', '!'}) // "world!"
30 _ = myString([]myByte{'\xf0', '\x9f', '\x8c', '\x8d'}) // "🌍
33 _ = string([]rune{0x767d, 0x9d6c, 0x7fd4}) // "\u767d\u9d6c\u7fd4" == "白鵬翔"
34 _ = string([]rune{}) // ""
35 _ = string([]rune(nil)) // ""
38 _ = string(runes{0x767d, 0x9d6c, 0x7fd4}) // "\u767d\u9d6c\u7fd4" == "白鵬翔"
41 _ = string([]myRune{0x266b, 0x266c}) // "\u266b\u266c" == "♫♬"
42 _ = myString([]myRune{0x1f30e}) // "\U0001f30e" == "🌎
45 _ = []byte("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
46 _ = []byte("") // []byte{}
48 _ = bytes("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
50 _ = []myByte("world!") // []myByte{'w', 'o', 'r', 'l', 'd', '!'}
51 _ = []myByte(myString("🌏")) // []myByte{'\xf0', '\x9f', '\x8c', '\x8f'}
54 _ = []rune(myString("白鵬翔")) // []rune{0x767d, 0x9d6c, 0x7fd4}
55 _ = []rune("") // []rune{}
57 _ = runes("白鵬翔") // []rune{0x767d, 0x9d6c, 0x7fd4}
59 _ = []myRune("♫♬") // []myRune{0x266b, 0x266c}
60 _ = []myRune(myString("🌐")) // []myRune{0x1f310}