Daily bump.
[official-gcc.git] / libgo / go / strconv / quote_example_test.go
blob405a57eb576a410c2c6351eaa75ffc4b3f774435
1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package strconv_test
7 import (
8 "fmt"
9 "strconv"
12 func ExampleUnquote() {
13 test := func(s string) {
14 t, err := strconv.Unquote(s)
15 if err != nil {
16 fmt.Printf("Unquote(%#v): %v\n", s, err)
17 } else {
18 fmt.Printf("Unquote(%#v) = %v\n", s, t)
22 s := `cafe\u0301`
23 // If the string doesn't have quotes, it can't be unquoted.
24 test(s) // invalid syntax
25 test("`" + s + "`")
26 test(`"` + s + `"`)
28 test(`'\u00e9'`)
30 // Output:
31 // Unquote("cafe\\u0301"): invalid syntax
32 // Unquote("`cafe\\u0301`") = cafe\u0301
33 // Unquote("\"cafe\\u0301\"") = café
34 // Unquote("'\\u00e9'") = é