From b73eed44d281e4b4ff308f062aeb3958e6a4e49d Mon Sep 17 00:00:00 2001 From: oluceps Date: Mon, 11 Nov 2024 02:11:15 +0800 Subject: [PATCH] + parser fit multibytes input --- src/helper/template.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/helper/template.rs b/src/helper/template.rs index d39a7de..871cdae 100644 --- a/src/helper/template.rs +++ b/src/helper/template.rs @@ -24,7 +24,13 @@ pub fn extract_all_hashes<'a>(input: &'a str, res: &mut Vec<&'a str>) { // less than expected `{{ hash }}` length return; } else { - let this = &input[1..]; + let this = { + // handle multibytes + let res = input.char_indices().nth(1).map_or("", |(i, _)| &input[i..]); + // skip to next `{` + res.find('{').map_or("", |index| &res[index..]) + }; + extract_all_hashes(this, res) } }