diff --git a/CHANGELOG.md b/CHANGELOG.md index ce2ce41..b5da2e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.3.2 - TBD +- Fixed handling of unicode characters immediately adjacent to timestamps + ## 0.3.1 - 2025-12-03 - Add pre-built binaries to the release artifacts diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 8ddae1d..483134e 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -60,7 +60,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -info@nautechsystems.io. +support@databento.com. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the diff --git a/Cargo.toml b/Cargo.toml index 2bd429a..bbf2b90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "epoch-to" authors = ["Databento "] -version = "0.3.1" +version = "0.3.2" edition = "2021" repository = "https://github.com/databento/epoch" description = "CLI tool for converting UNIX timestamps to human-readable date strings" diff --git a/src/main.rs b/src/main.rs index 7552a59..05b8354 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,8 @@ impl Reformatter { // isn't a number, so print it as `text_after` let (number_end, text_after) = text_iter .find(|(_, c)| !NUMBERS.contains(c)) - .map(|(i, _)| (i, &line[i..i + 1])) + // len_utf8 to handle multi-byte chars + .map(|(i, c)| (i, &line[i..i + c.len_utf8()])) .unwrap_or_else(|| (line.len(), "")); // If the length of the number is less than that of the lower second bound, can skip parsing @@ -110,8 +111,8 @@ impl Reformatter { continue; } } - // plus 1 for text_after - let text = &line[text_start..(number_end + 1).min(line.len())]; + // plus text_after length (which may be multi-byte) + let text = &line[text_start..(number_end + text_after.len()).min(line.len())]; write!(writer, "{text}",)?; } Ok(()) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index fab58ab..c801267 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1,4 +1,4 @@ -use assert_cmd::Command; +use assert_cmd::{cargo::cargo_bin_cmd, Command}; use predicates::{ boolean::PredicateBooleanExt, ord::eq, @@ -7,7 +7,7 @@ use predicates::{ use rstest::*; fn cmd() -> Command { - Command::cargo_bin("epoch").unwrap() + cargo_bin_cmd!("epoch") } #[rstest] @@ -23,6 +23,8 @@ fn cmd() -> Command { "Deserializationµs=547.261 1709152989", "Deserializationµs=547.261 2024-02-28T20:43:09Z" )] +#[case::symbol_adjacent("€1709152989¥", "€2024-02-28T20:43:09Z¥")] +#[case::symbol_adjacent("東京1709152989서울", "東京2024-02-28T20:43:09Z서울")] fn test_replacement(#[case] stdin: &str, #[case] stdout: &str) { cmd() .write_stdin(format!("{stdin}\n"))