I have a C project (ISO 8859-1 encoded) in the STM32CubeMX IDE, and I want to add Git log information in a header file in order to use those in my software (print it in the terminal).
My whole project is ISO 8859-1 encoded, and Git uses the default UTF-8 for commit, so for log too.
The Git command I have is:
git log -n 1 --date=format:"%H:%M %d/%m/%Y" --encoding=ISO-8859-1 --pretty=format:"#ifndef GITCOMMIT_H_%n#define GITCOMMIT_H_%n%n#define AUTHOR_NAME '%an'%n#define COMMIT_HASH '%h'%n#define DATE '%cd'%n%n#endif" > src\gitcommit.h
But when I compiled I got the error:
../gitcommit.h:1:1: error: stray '\377' in program
1 | ÿþ# i f n d e f G I T C O M M I T _ H _
And other errors all along the line.
How can I fix this?
As I am on Windows, when I create the header file with the ">" operator, it is automatically encoded in UTF-16LE.