Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding of lexical file and it generates flex.cpp file #32

Open
Wzshun opened this issue Feb 13, 2019 · 4 comments
Open

Encoding of lexical file and it generates flex.cpp file #32

Wzshun opened this issue Feb 13, 2019 · 4 comments
Labels
Flex Issues related to Flex

Comments

@Wzshun
Copy link

Wzshun commented Feb 13, 2019

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.

@lexxmark
Copy link
Owner

Sorry I don't know how to use UTF-8 input for flex.
Try to google this problem.

@lexxmark
Copy link
Owner

This discussion may help you

@Wzshun
Copy link
Author

Wzshun commented Feb 20, 2019

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.

@GitMensch GitMensch added the Flex Issues related to Flex label Jun 22, 2021
@taoyouh
Copy link

taoyouh commented Dec 27, 2022

There are 2 ways to make Visual C++ treat source code as UTF-8:

  1. add argument /source-charset:utf-8 in the command line (the "command-line" settings in the project)
  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Flex Issues related to Flex
Projects
None yet
Development

No branches or pull requests

4 participants