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

Harald van Dijk via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 05:42:09 PDT 2026


================
@@ -0,0 +1,28 @@
+## Show that llvm-strings uses the specified encoding.
+
+RUN: echo a > %t
+RUN: echo ab >> %t
+RUN: echo abc >> %t
+RUN: echo abcd >> %t
+RUN: echo abcd€ >> %t
+
+# Check that long form options work.
+RUN: llvm-strings --encoding s 2>&1 %t | FileCheck --check-prefixes CHECK,CHECK-ASCII %s
+RUN: llvm-strings --encoding S 2>&1 %t | FileCheck                                    %s
----------------
hvdijk wrote:

> if I'm not mistaken, if you added CHECK-LOCALE to the `s` test case prefixes, you'd still get a passing test regardless of locale

On Linux systems, kinda sorta but only because `llvm-lit` doesn't preserve the locale-affecting environment variables so that the test always runs in the C locale where `-e s` and `-e S` are equivalent. If you run the test manually, with those variables preserved, the test can fail that way. On Windows, where the character set is not controlled by environment variables, the test can also fail that way.

I'll add a comment explaining this.

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


More information about the llvm-commits mailing list