I think allowing String.toByteArray(null) to perform default string to byes is confusing. Why not create two overloaded methods, one without parameter, and then second with non-null able encode param?
On top of this there is also String.toByteArray(encode : Charset) declared. Obviously this is not-nullable, and that’s the only reason it compiles I suppose. But to me, allowing String.toByteArray(null) is ugly and confusing.