Skip to main content

reifydb_core/util/encoding/
binary.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2// Copyright (c) 2026 ReifyDB
3
4pub fn decode_binary(s: &str) -> Vec<u8> {
5	let mut buf = [0; 4];
6	let mut bytes = Vec::new();
7	for c in s.chars() {
8		match c as u32 {
9			b @ 0x80..=0xff => bytes.push(b as u8),
10			_ => bytes.extend(c.encode_utf8(&mut buf).as_bytes()),
11		}
12	}
13	bytes
14}