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

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 01:40:07 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
----------------
jh7370 wrote:

> Windows users will also always get an UTF-8 encoded file.

Not if the file is created/saved on Windows in the first place. To be more precise, it'll depend on the text editor used when last saving the file. I wouldn't be surprised if there are editors that might read a UTF-8 file but then save in a different encoding. Certainly, I can change the encoding manually in e.g. Sublime Text.

> I think FileCheck doesn't support the same, we need a literal € in the file anyway, or is there an option there I'm missing?

Quite possibly there isn't explicitly a method (I suggested \u in regexes, but I also wouldn't be surprised if it's not available). One option would be to use printf to build up the check pattern in a file on disk, then specify this file rather than `%s` in the FileCheck command-line. It's a little janky, but it would allow us complete control (or you could write a small python script in the test to achieve the same thing rather than using printf). Finally, there's always the option of enhancing FileCheck somehow. This would probably be the cleanest option, once we've figured out how to plumb it together, but obviously a lot more work.

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


More information about the llvm-commits mailing list