[llvm] [llvm-strings] Add --encoding={s,S,u} option (PR #221794)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 01:14:40 PDT 2026


================
@@ -149,17 +230,35 @@ int main(int argc, char **argv) {
     return 0;
   }
 
+  const auto *EncodingArg = Args.getLastArg(OPT_encoding_EQ);
+
+  Encoding = EncodingArg ? llvm::StringSwitch<encoding>(EncodingArg->getValue())
+                               .Case("s", encoding::s)
+                               .Case("S", encoding::S)
+                               .Case("u", encoding::u)
+                               .Predicate(
+                                   [](StringRef) -> bool {
+                                     reportCmdLineError(
+                                         "--encoding value should be one of: "
+                                         "'s' (ASCII characters), "
+                                         "'S' (characters in the system's or "
+                                         "user's selected character set), "
+                                         "'u' (UTF-8 characters)");
+                                   },
----------------
jh7370 wrote:

I don't think you need to go into this detail in the error message. Suffice to say would be `--encoding value 'x' is unknown` (where 'x' is the specified value). The help text should contain the correct values.

https://github.com/llvm/llvm-project/pull/221794


More information about the llvm-commits mailing list