Convert a string to a null-terminated bytes object.
(s, length, encoding, errors)
| 155 | #--------------------------------------------------------- |
| 156 | |
| 157 | def stn(s, length, encoding, errors): |
| 158 | """Convert a string to a null-terminated bytes object. |
| 159 | """ |
| 160 | if s is None: |
| 161 | raise ValueError("metadata cannot contain None") |
| 162 | s = s.encode(encoding, errors) |
| 163 | return s[:length] + (length - len(s)) * NUL |
| 164 | |
| 165 | def nts(s, encoding, errors): |
| 166 | """Convert a null-terminated bytes object to a string. |
no test coverage detected