basic introduction
Golang no special character types, if you want to store a single character (letter) is generally used to store the byte.
Character string is a string of fixed length connecting the character sequence. Go strings are connected by a single byte. That is the traditional string is made up of characters, and different Go strings, it is by bytes.
Case presentation
Code Description of above
1) If we save characters in the ASCII table, such as [0-1, az, AZ ..] may be saved directly to byte
2) If we save the code corresponding to the character value greater than 255, then we can consider using an int save
3) If we need to install the character mode output, then we need to format the output, i.e. fmt.Printf ( "% c", c1 ) ..
Details character type
1) is a single quote character constants ( '') enclose a single character. For example: var c1 byte = 'a' var c2 int = ' in' byte var C3 = '. 9'
2) Go are allowed escape character '\' subsequent to the special characters into a character constant. For example: var char C3 = '\ n-'
// '\ n-' represents a newline
character 3) Go language using UTF-8 encoding, if you want to search the character code value corresponding to utf8
http://www.mytju.com/ classcode / tools / encode_utf8.asp
alphabet characters -3 -1 bytes bytes
4) in Go, the nature of the character is an integer, when the direct output, a code value corresponding to the UTF-8 character encoding.
5) can be directly assigned to a variable, a number, and then press the formatted output% c, of the digital outputs corresponding unicode character
6) The character type may be made of operation, equivalent to an integer, because it corresponds to Unicode code has
To investigate the nature of the character type
1) is stored in the computer character, the character corresponding to the code value (integer) need to find out the store: character ---> code value corresponding to> Binary -> Storage
reading: Binary ----> code value ----> character -> read
2) correspondence between the character and the code value is determined by the character code table (is ordained)
3) Go coded language have become unified utf-8. Very convenient, very uniform, no coding garbled troubled