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

g_force_unicode is not set when reading utf8 files #13

Open
mingodad opened this issue Aug 27, 2023 · 2 comments
Open

g_force_unicode is not set when reading utf8 files #13

mingodad opened this issue Aug 27, 2023 · 2 comments

Comments

@mingodad
Copy link

Looking through the code, the show_help() says:

-utf8          In the absence of a BOM assume UTF-8

If we have a grammar that is/use utf8 it's not detected so we need to use -utf8 to really get a utf8 parser/lexer from our grammar.

Am I missing something here ?

@mingodad
Copy link
Author

Also it's always opening the grammar with lexertl::citerator here

iter = lexertl::citerator(_mf.data(), _mf.data() + _mf.size(),
instead of detecting if the input grammar is/use utf8.

@mingodad
Copy link
Author

Here is an example grammar:

%token au_accented
%%
start: au_accented ;
%%
%%
[ \t\n\r]	skip()
[áéíóú]	au_accented
%%

e_utf8.txt:

é

E_utf8.txt:

É

Outputs:

./gram_grep -f au_utf8.g e_utf8.txt 
./e_utf8.txt(1):é
./e_utf8.txt(1):é
Matches: 2    Matching files: 1    Total files searched: 1
...
./gram_grep -f au_utf8.g E_utf8.txt 
./E_utf8.txt(1):É
Matches: 1    Matching files: 1    Total files searched: 1
...
./gram_grep -utf8 -f au_utf8.g e_utf8.txt 
Matches: 0    Matching files: 0    Total files searched: 1
...
./gram_grep -utf8 -f au_utf8.g E_utf8.txt 
Matches: 0    Matching files: 0    Total files searched: 1

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

No branches or pull requests

1 participant