@@ -129,8 +129,9 @@ impl<'a> From<&'a str> for Shellwords<'a> {
129129 DquoteEscaped => Dquoted,
130130 };
131131
132β if i >= input.len() - 1 && end == 0 {
133β end = i + 1;
132+ let c_len = c.len_utf8();
133+ if i == input.len() - c_len && end == 0 {
134+ end = i + c_len;
134135 }
135136
136137 if end > 0 {
@@ -333,4 +334,17 @@ mod test {
333334 assert_eq!(Shellwords::from(":o a").parts(), &[":o", "a"]);
334335 assert_eq!(Shellwords::from(":o a\\ ").parts(), &[":o", "a\\"]);
335336 }
337+
338+ #[test]
339+ fn test_multibyte_at_end() {
340+ assert_eq!(Shellwords::from("π").parts(), &["π"]);
341+ assert_eq!(
342+ Shellwords::from(":sh echo π").parts(),
343+ &[":sh", "echo", "π"]
344+ );
345+ assert_eq!(
346+ Shellwords::from(":sh echo π hello worldπ").parts(),
347+ &[":sh", "echo", "π", "hello", "worldπ"]
348+ );
349+ }
336350}