use ;
/// Automatically detects the encoding and decodes a byte sequence into a UTF-8 string.
///
/// Tries UTF-8, GBK, and BIG5 encodings in order. If the decoded result contains the
/// Unicode replacement character (`\u{FFFD}`), the current encoding is considered a
/// mismatch and the next one is tried.
///
/// Returns an empty string `""` if none of the three encodings can decode losslessly.
///
/// # Use Cases
///
/// Primarily used for MySQL `VARBINARY` and `TEXT` (non-UTF-8 byte streams) as well as
/// PostgreSQL `bytea` columns, called after [`crate::to_json::blob_is_text`] determines
/// that the data is human-readable text.
///
/// # Example
///
/// ```rust
/// use dbcli::decode::decode_auto;
///
/// // UTF-8 bytes
/// let bytes = b"Hello, \xe4\xb8\x96\xe7\x95\x8c";
/// let s = decode_auto(bytes);
/// assert_eq!(s, "Hello, \u{4e16}\u{754c}");
/// ```