Example #1
0
File: util.go Project: Anaminus/pkm
// Decode a string from a Reader, delimited by string terminator, using
// default encoding.
func readTextString(r io.Reader) string {
	b := make([]byte, 0, 32)
	q := make([]byte, 1)
	for {
		if _, err := r.Read(q); err == io.EOF || q[0] == strTerm {
			break
		}
		b = append(b, q[0])
	}
	s, _ := pkm.DecodeText(defaultCodec, b)
	return s
}
Example #2
0
File: util.go Project: Anaminus/pkm
// Truncate and decode a slice into a string, using default encoding.
func decodeTextString(b []byte) string {
	s, _ := pkm.DecodeText(defaultCodec, truncateText(b))
	return s
}