mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-07-08 01:31:53 +08:00
Support remove zero width space
This commit is contained in:
@@ -58,6 +58,8 @@ impl<'a> M3tParser<'a> {
|
|||||||
if line.is_empty() {
|
if line.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// Remove zero-width space characters
|
||||||
|
let line = line.trim().trim_matches('\u{200b}');
|
||||||
if line.starts_with("○") {
|
if line.starts_with("○") {
|
||||||
let line = line[3..].trim();
|
let line = line[3..].trim();
|
||||||
if !line.starts_with("NAME:") {
|
if !line.starts_with("NAME:") {
|
||||||
@@ -128,6 +130,8 @@ impl<'a> M3tParser<'a> {
|
|||||||
if line.is_empty() {
|
if line.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// Remove zero-width space characters
|
||||||
|
let line = line.trim().trim_matches('\u{200b}');
|
||||||
if line.starts_with("○") {
|
if line.starts_with("○") {
|
||||||
let line = line[3..].trim();
|
let line = line[3..].trim();
|
||||||
if line.starts_with("NAME:") {
|
if line.starts_with("NAME:") {
|
||||||
@@ -204,3 +208,13 @@ impl M3tDumper {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_zero_width_space() {
|
||||||
|
let input = "○ NAME: Example\n\n○ Original message\n\u{200b}● 「」\n\n";
|
||||||
|
let mut parser = M3tParser::new(input, None);
|
||||||
|
let messages = parser.parse().unwrap();
|
||||||
|
assert_eq!(messages.len(), 1);
|
||||||
|
let map = M3tParser::new(input, None).parse_as_map().unwrap();
|
||||||
|
assert_eq!(map.len(), 1);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user