当前位置: 首页>>代码示例>>Golang>>正文


Golang strconv.IsPrint函数代码示例

本文整理汇总了Golang中strconv.IsPrint函数的典型用法代码示例。如果您正苦于以下问题:Golang IsPrint函数的具体用法?Golang IsPrint怎么用?Golang IsPrint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了IsPrint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ExampleIsPrint

func ExampleIsPrint() {
	c := strconv.IsPrint('\u263a')
	fmt.Println(c)

	bel := strconv.IsPrint('\007')
	fmt.Println(bel)

	// Output:
	// true
	// false
}
开发者ID:RajibTheKing,项目名称:gcc,代码行数:11,代码来源:example_test.go

示例2: appendQuoted

func appendQuoted(buf []byte, s string) []byte {
	var runeTmp [utf8.UTFMax]byte
	for width := 0; len(s) > 0; s = s[width:] {
		r := rune(s[0])
		width = 1
		if r >= utf8.RuneSelf {
			r, width = utf8.DecodeRuneInString(s)
		}
		if width == 1 && r == utf8.RuneError {
			buf = append(buf, `\x`...)
			buf = append(buf, lowerhex[s[0]>>4])
			buf = append(buf, lowerhex[s[0]&0xF])
			continue
		}
		if r == rune('"') || r == '\\' { // always backslashed
			buf = append(buf, '\\')
			buf = append(buf, byte(r))
			continue
		}
		if strconv.IsPrint(r) {
			n := utf8.EncodeRune(runeTmp[:], r)
			buf = append(buf, runeTmp[:n]...)
			continue
		}
		buf = appendRune(buf, s, r)
	}
	return buf
}
开发者ID:emccode,项目名称:libstorage,代码行数:28,代码来源:handlers_logging.go

示例3: ProgString

func (s sliceExpr) ProgString() string {
	var b bytes.Buffer
	// If it's all Char, we can do a prettier job.
	if s.allChars() {
		b.WriteRune('\'')
		for _, v := range s {
			c := rune(v.(value.Char))
			esc := charEscape[c]
			if esc != "" {
				b.WriteString(esc)
				continue
			}
			if !strconv.IsPrint(c) {
				if c <= 0xFFFF {
					fmt.Fprintf(&b, "\\u%04x", c)
				} else {
					fmt.Fprintf(&b, "\\U%08x", c)
				}
				continue
			}
			b.WriteRune(c)
		}
		b.WriteRune('\'')
	} else {
		for i, v := range s {
			if i > 0 {
				b.WriteRune(' ')
			}
			b.WriteString(v.ProgString())
		}
	}
	return b.String()
}
开发者ID:nathangrigg,项目名称:ivy,代码行数:33,代码来源:parse.go

示例4: HandleRegister

func (this *Handler) HandleRegister(login string, password string) string {
	result := map[string]string{"result": "ok"}
	salt := time.Now().Unix()
	fmt.Println("register salt: ", salt)
	hash := GetMD5Hash(password + strconv.Itoa(int(salt)))
	passHasInvalidChars := false
	for i := 0; i < len(password); i++ {
		if strconv.IsPrint(rune(password[i])) == false {
			passHasInvalidChars = true
			break
		}
	}
	isExist, _, _, _ := IsExist(login)
	if isExist == true {
		result["result"] = "loginExists"
	} else if !MatchRegexp("^[a-zA-Z0-9]{2,36}$", login) {
		result["result"] = "badLogin"
	} else if !MatchRegexp("^.{6,36}$", password) && !passHasInvalidChars {
		result["result"] = "badPassword"
	} else {
		db := connect.DBConnect()
		query := connect.DBInsert("users", []string{"login", "password", "salt"})
		stmt, err := db.Prepare(query)
		utils.HandleErr("[HandleRegister] Prepare error :", err)
		defer stmt.Close()
		_, err = stmt.Exec(login, hash, salt)
		utils.HandleErr("[HandleRegister] Query error :", err)
	}
	response, err := json.Marshal(result)
	utils.HandleErr("[HandleRegister] json.Marshal: ", err)
	return string(response)
}
开发者ID:GuraYaroslava,项目名称:unified-accounting-system,代码行数:32,代码来源:auth.go

示例5: Register

func (this *RegistrationController) Register(login, password, email, role string) (result string, regId int) {
	result = "ok"
	salt := strconv.Itoa(int(time.Now().Unix()))
	pass := utils.GetMD5Hash(password + salt)

	passHasInvalidChars := false
	for i := 0; i < len(password); i++ {
		if strconv.IsPrint(rune(password[i])) == false {
			passHasInvalidChars = true
			break
		}
	}

	if db.IsExists("users", []string{"login"}, []interface{}{login}) == true {
		result = "loginExists"

	} else if !utils.MatchRegexp("^[a-zA-Z0-9]{2,36}$", login) {
		result = "badLogin"

	} else if !utils.MatchRegexp("^.{6,36}$", password) || passHasInvalidChars {
		result = "badPassword"

		// } else if bad email {

	} else {
		token := utils.GetRandSeq(HASH_SIZE)

		if !mailer.SendConfirmEmail(login, email, token) {
			return "badEmail", -1
		}

		var userId int
		this.GetModel("users").
			LoadModelData(map[string]interface{}{
				"login":   login,
				"pass":    pass,
				"salt":    salt,
				"role":    role,
				"token":   token,
				"enabled": false}).
			QueryInsert("RETURNING id").
			Scan(&userId)

		var faceId int
		this.GetModel("faces").
			LoadModelData(map[string]interface{}{"user_id": userId}).
			QueryInsert("RETURNING id").
			Scan(&faceId)

		this.GetModel("registrations").
			LoadModelData(map[string]interface{}{"face_id": faceId, "event_id": 1, "status": false}).
			QueryInsert("RETURNING id").
			Scan(&regId)

		return result, regId
	}

	return result, -1
}
开发者ID:FooBarrior,项目名称:orc,代码行数:59,代码来源:registration_controller.go

示例6: cprotect

//  cprotect returns its argument if printable, else a backslash form.
func cprotect(r rune) string {
	if strconv.IsPrint(r) {
		return string(r)
	} else {
		s := strconv.QuoteRune(r)
		return s[1 : len(s)-1]
	}
}
开发者ID:proebsting,项目名称:re,代码行数:9,代码来源:charset.go

示例7: isPrintableString

/*
Returns true when the string is entirely made of printable runes, false otherwise.
*/
func isPrintableString(str string) bool {
	for _, runeValue := range str {
		if !strconv.IsPrint(runeValue) {
			return false
		}
	}
	return true
}
开发者ID:cloudfoundry-incubator,项目名称:cf-mysql-bootstrap,代码行数:11,代码来源:format.go

示例8: String

func (v *OctetString) String() string {
	for _, c := range v.Value {
		if !strconv.IsPrint(rune(c)) {
			return toHexStr(v.Value, ":")
		}
	}
	return string(v.Value)
}
开发者ID:yulianghsueh,项目名称:snmpgo,代码行数:8,代码来源:variables.go

示例9: isValueBinary

func isValueBinary(value []byte) bool {
	for _, r := range value {
		if strconv.IsPrint(rune(r)) == false {
			return true
		}
	}
	return false
}
开发者ID:jsimonetti,项目名称:ldapserv,代码行数:8,代码来源:add.go

示例10: isPrint

func isPrint(s string) bool {
	for _, c := range s {
		if !strconv.IsPrint(c) {
			return false
		}
	}

	return true
}
开发者ID:Cl0udPhish,项目名称:go-swagger,代码行数:9,代码来源:convert.go

示例11: fmt_unicode

// fmt_unicode formats a uint64 as "U+0078" or with f.sharp set as "U+0078 'x'".
func (f *fmt) fmt_unicode(u uint64) {
	buf := f.intbuf[0:]

	// With default precision set the maximum needed buf length is 18
	// for formatting -1 with %#U ("U+FFFFFFFFFFFFFFFF") which fits
	// into the already allocated intbuf with a capacity of 68 bytes.
	prec := 4
	if f.precPresent && f.prec > 4 {
		prec = f.prec
		// Compute space needed for "U+" , number, " '", character, "'".
		width := 2 + prec + 2 + utf8.UTFMax + 1
		if width > len(buf) {
			buf = make([]byte, width)
		}
	}

	// Format into buf, ending at buf[i]. Formatting numbers is easier right-to-left.
	i := len(buf)

	// For %#U we want to add a space and a quoted character at the end of the buffer.
	if f.sharp && u <= utf8.MaxRune && strconv.IsPrint(rune(u)) {
		i--
		buf[i] = '\''
		i -= utf8.RuneLen(rune(u))
		utf8.EncodeRune(buf[i:], rune(u))
		i--
		buf[i] = '\''
		i--
		buf[i] = ' '
	}
	// Format the Unicode code point u as a hexadecimal number.
	for u >= 16 {
		i--
		buf[i] = udigits[u&0xF]
		prec--
		u >>= 4
	}
	i--
	buf[i] = udigits[u]
	prec--
	// Add zeros in front of the number until requested precision is reached.
	for prec > 0 {
		i--
		buf[i] = '0'
		prec--
	}
	// Add a leading "U+".
	i--
	buf[i] = '+'
	i--
	buf[i] = 'U'

	oldZero := f.zero
	f.zero = false
	f.pad(buf[i:])
	f.zero = oldZero
}
开发者ID:Harvey-OS,项目名称:go,代码行数:58,代码来源:format.go

示例12: IsPrintable

func (v *SnmpOctetString) IsPrintable() bool {
	isPrintable := true
	for _, c := range []byte(*v) {
		if !strconv.IsPrint(rune(c)) {
			isPrintable = false
			break
		}
	}
	return isPrintable
}
开发者ID:runner-mei,项目名称:snmpclient,代码行数:10,代码来源:snmpvalue.go

示例13: quote

func quote(b byte) string {
	switch b {
	case '\'', '"', '`':
		return string(rune(b))
	}
	if b < utf8.RuneSelf && strconv.IsPrint(rune(b)) {
		return strconv.QuoteRune(rune(b))
	}
	return fmt.Sprintf(`%.2x`, b)
}
开发者ID:h12w,项目名称:dfa,代码行数:10,代码来源:dump.go

示例14: _isPrint

// _isPrint() returns true if str is printable
//
// @private method
func _isPrint(str string) bool {
	for _, c := range str {

		if !strconv.IsPrint(rune(c)) {
			return false
		}
	}

	return true
}
开发者ID:nlopes,项目名称:openldap,代码行数:13,代码来源:openldap.go

示例15: prepareBuf

func (c *asciiChunk) prepareBuf() {
	for i := 0; i < len(c.buf); i++ {
		for {
			c.nextAscii = (c.nextAscii + 1) % 128
			if strconv.IsPrint(rune(c.nextAscii)) && c.nextAscii != '\n' {
				break
			}
		}
		c.buf[i] = c.nextAscii
	}
}
开发者ID:tobor,项目名称:proxy,代码行数:11,代码来源:chunked_handler.go


注:本文中的strconv.IsPrint函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。