winflexbison
winflexbison copied to clipboard
Encoding of lexical file and it generates flex.cpp file
In the past, I can write UTF-8 char in my lexical file and it work well. But, after some days, maybe I change visual studio generate .cpp encoding, the VS template file? I can't remember exactly. The VS warning flex.cpp file contains a character that cannot be represented in the current code page (936). ( Chinese GB2312 ) , and compile fail, output mystery error.
So, how can I use UTF-8 char in lexical file? or how to set VS settings properly? Now I only use them in comment, so i can change them to english, and it work well, but maybe I will need to recognize them in the future.
I use flex/bison 2.4.6/2.5.6 and vs 2013. Sorry for my poor English.
Sorry I don't know how to use UTF-8 input for flex. Try to google this problem.
This discussion may help you
This discussion may help you
I have checked it, but I means that the problem maybe in my Visual Studio 2013 settings which i don't know what will impact on Flex output.
There are 2 ways to make Visual C++ treat source code as UTF-8:
- add argument
/source-charset:utf-8
in the command line (the "command-line" settings in the project) - add BOM to the source (.cpp) file
If you want to use utf-8 in both execution charset and source charset, you can add argument /utf-8
in the compiler command line.