I need to read [100]byte
to transfer a bunch of string
data.
Because not all of the string
s are precisely 100 characters long, the remaining part of the byte array
are padded with 0
s.
If I tansfer [100]byte
to string
by: string(byteArray[:])
, the tailing 0
s are displayed as ^@^@
s.
In C the string
will terminate upon 0
, so I wonder what's the best way of smartly transfer a byte array
to string
in Golang.
转载于:https://stackoverflow.com/questions/14230145/what-is-the-best-way-to-convert-byte-array-to-string