From 1573523feaaf8fa9753528c64708825f4bfa5ab0 Mon Sep 17 00:00:00 2001 From: coyaSONG <66289470+coyaSONG@users.noreply.github.com> Date: Tue, 14 Jul 2026 17:26:10 +0900 Subject: [PATCH] Clarify std::env::args encoding requirements --- src/ch12-01-accepting-command-line-arguments.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ch12-01-accepting-command-line-arguments.md b/src/ch12-01-accepting-command-line-arguments.md index 46f2f37f00..b3cf446eed 100644 --- a/src/ch12-01-accepting-command-line-arguments.md +++ b/src/ch12-01-accepting-command-line-arguments.md @@ -59,9 +59,10 @@ mistaken for a function that’s defined in the current module. > ### The `args` Function and Invalid Unicode > -> Note that `std::env::args` will panic if any argument contains invalid -> Unicode. If your program needs to accept arguments containing invalid -> Unicode, use `std::env::args_os` instead. That function returns an iterator +> Note that `std::env::args` will panic if any argument can’t be represented as +> a valid Rust `String`. This includes arguments that aren’t valid UTF-8 on Unix +> or aren’t valid UTF-16 on Windows. If your program needs to accept such +> arguments, use `std::env::args_os` instead. That function returns an iterator > that produces `OsString` values instead of `String` values. We’ve chosen to > use `std::env::args` here for simplicity because `OsString` values differ per > platform and are more complex to work with than `String` values.