libgo: update to Go 1.11
[official-gcc.git] / libgo / go / strconv / doc.go
blobcba898426afe760c5bc09e2496a0463b3ffa0131
1 // Copyright 2015 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 implements conversions to and from string representations
6 // of basic data types.
7 //
8 // Numeric Conversions
9 //
10 // The most common numeric conversions are Atoi (string to int) and Itoa (int to string).
12 // i, err := strconv.Atoi("-42")
13 // s := strconv.Itoa(-42)
15 // These assume decimal and the Go int type.
17 // ParseBool, ParseFloat, ParseInt, and ParseUint convert strings to values:
19 // b, err := strconv.ParseBool("true")
20 // f, err := strconv.ParseFloat("3.1415", 64)
21 // i, err := strconv.ParseInt("-42", 10, 64)
22 // u, err := strconv.ParseUint("42", 10, 64)
24 // The parse functions return the widest type (float64, int64, and uint64),
25 // but if the size argument specifies a narrower width the result can be
26 // converted to that narrower type without data loss:
28 // s := "2147483647" // biggest int32
29 // i64, err := strconv.ParseInt(s, 10, 32)
30 // ...
31 // i := int32(i64)
33 // FormatBool, FormatFloat, FormatInt, and FormatUint convert values to strings:
35 // s := strconv.FormatBool(true)
36 // s := strconv.FormatFloat(3.1415, 'E', -1, 64)
37 // s := strconv.FormatInt(-42, 16)
38 // s := strconv.FormatUint(42, 16)
40 // AppendBool, AppendFloat, AppendInt, and AppendUint are similar but
41 // append the formatted value to a destination slice.
43 // String Conversions
45 // Quote and QuoteToASCII convert strings to quoted Go string literals.
46 // The latter guarantees that the result is an ASCII string, by escaping
47 // any non-ASCII Unicode with \u:
49 // q := Quote("Hello, 世界")
50 // q := QuoteToASCII("Hello, 世界")
52 // QuoteRune and QuoteRuneToASCII are similar but accept runes and
53 // return quoted Go rune literals.
55 // Unquote and UnquoteChar unquote Go string and rune literals.
57 package strconv