self
var b = "102041426E6F1020" .hexdigest_to_bytes
assert b.trim.hexdigest == "41426E6F"
NOTE: A whitespace is defined here as a byte whose value is <= 0x20
# Trims off the whitespaces at the beginning and the end of `self`
#
# var b = "102041426E6F1020" .hexdigest_to_bytes
# assert b.trim.hexdigest == "41426E6F"
#
# NOTE: A whitespace is defined here as a byte whose value is <= 0x20
fun trim: Bytes do
var st = 0
while st < length do
if self[st] > 0x20 then break
st += 1
end
if st >= length then return new Bytes.empty
var ed = length - 1
while ed > 0 do
if self[ed] > 0x20 then break
ed -= 1
end
return slice(st, ed - st + 1)
end
lib/core/bytes.nit:289,2--308,4