use base64::Engine as _;
pub fn osc52(text: &str) -> String {
let encoded = base64::engine::general_purpose::STANDARD.encode(text);
format!("\x1b]52;c;{encoded}\x07")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_payload_is_base64_in_a_clipboard_sequence() {
assert_eq!(osc52("abc"), "\x1b]52;c;YWJj\x07");
assert_eq!(osc52("foo"), "\x1b]52;c;Zm9v\x07");
assert_eq!(osc52(""), "\x1b]52;c;\x07");
}
#[test]
fn both_padding_lengths_and_non_ascii_encode() {
assert_eq!(osc52("f"), "\x1b]52;c;Zg==\x07");
assert_eq!(osc52("fo"), "\x1b]52;c;Zm8=\x07");
assert_eq!(osc52("\u{e9}"), "\x1b]52;c;w6k=\x07");
}
}