It's not who you are underneath, it's what you do that defines you

Brick walls are there for a reason :they let us prove how badly we want things

rune 切片 go


package main

import (
	"fmt"
)

func main() {
	var s = "go程序``**//;;''[p]=-\\&|@#$%^"
	var r = []rune(s)
	for i := 0; i < len(s); i++ {
		fmt.Printf("%q \n", s[i])
	}
	fmt.Printf("-----  \n")
	for i := 0; i < len(r); i++ {
		fmt.Printf("%q \n ", r[i])
	}

	//var pwd = golibs.GetPwd(2)
	//log.Println("password:", pwd)
}

  

打印结果如下:

API server listening at: 127.0.0.1:14663
'g'
'o'
'ç'
'¨'
'\u008b'
'å'
'º'
'\u008f'
'`'
'`'
'*'
'*'
'/'
'/'
';'
';'
'\''
'\''
'['
'p'
']'
'='
'-'
'\\'
'&'
'|'
'@'
'#'
'$'
'%'
'^'
-----
'g'
'o'
'程'
'序'
'`'
'`'
'*'
'*'
'/'
'/'
';'
';'
'\''
'\''
'['
'p'
']'
'='
'-'
'\\'
'&'
'|'
'@'
'#'
'$'
'%'
'^'


可以看出rune打印的结果不管中英文还是特殊字符,都可以还原打印

posted @ 2018-01-09 16:17  gbat  阅读(334)  评论(0编辑  收藏  举报

It's not who you are underneath, it's what you do that defines you

Brick walls are there for a reason :they let us prove how badly we want things