[#BloombergLP-bdlde-Utf8Util-readIfValid] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlde.adoc[bdlde]::xref:BloombergLP/bdlde/Utf8Util.adoc[Utf8Util]::readIfValid :relfileprefix: ../../../ :mrdocs: Read from the specified `input` and copy _valid_ UTF‐8 (only) to the specified `outputBuffer` having the specified `outputBufferLength` (in bytes). Load the specified `status` with: * 0 if `input` reached `eof` without encountering any invalid UTF‐8 or prematurely exhausting `outputBuffer`. * A positive value if `input` was not completely read due to `outputBuffer` being filled (or nearly filled) without encountering any invalid UTF‐8. * A negative value from `ErrorStatus` if invalid UTF‐8 was encountered (without having written the invalid sequence to `outputBuffer`). Return the number of bytes of valid UTF‐8 written to 'outputBuffer. If no invalid UTF‐8 is encountered, or if `input` supports `sputbackc` with a putback buffer capacity of at least 4 bytes, `input` will be left positioned at the end of the valid UTF‐8 read, otherwise, `input` will be left in an unspecified state. The behavior is undefined unless `4 <= outputBufferLength`. Note that this function will stop reading `input` when less than 4 bytes of space remain in `outputBuffer` to prevent the possibility of a 4‐byte UTF‐8 sequence being truncated partway through. == Synopsis Declared in `<bdlde_utf8util.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static xref:BloombergLP/bdlde/Utf8Util/size_type.adoc[size_type] readIfValid( int* status, char* outputBuffer, xref:BloombergLP/bdlde/Utf8Util/size_type.adoc[size_type] outputBufferLength, std::streambuf* input); ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#