write_truncated_to_limited_bytes
No overview available.
def write_truncated_to_limited_bytes(
f: BinaryIO,
s: str,
limit: int,
encoding: str = utf-8
) - > int
Writes a string to a file-like object while ensuring the total output does not exceed a specified byte limit.
Parameters
| Name | Type | Description |
|---|---|---|
| f | BinaryIO | The file-like object or buffer where the encoded string will be written. |
| s | str | The input string to be encoded and written. |
| limit | int | The maximum number of bytes allowed to be written to the output. |
| encoding | str = utf-8 | The character encoding used to convert the string into bytes. |
Returns
| Type | Description |
|---|---|
int | The total number of bytes actually written to the file-like object. |