0

I know flex can only use utf-8.

Is there a way to take a unicode file(utf-16 LE) as input and convert it to utf-8 internally?

It receives a file name as input and opens and uses the Unicode file.

...
yyin = fopen("fname", "r");
yyparse();
fclose(yyin);
...
Ssss
  • 1
  • 2
  • What do you mean by a "Unicode file", exactly? – rici Jan 23 '22 at 15:25
  • Do you mean you want to take some other Unicode encoding, like UTF-32, and use it as the input? – Piotr Siupa Jan 23 '22 at 20:40
  • Yes, it is. I want to use utf-16 as input. – Ssss Jan 24 '22 at 01:03
  • I'm not aware of a way you can do it directly in flex. However, You could add a preprocessing step where you convert the input to UTF-8 and save it as a temporary file. Then you can pass the temporary file to the `fopen` instead of the original file. – Piotr Siupa Jan 24 '22 at 07:46
  • Similar question: https://stackoverflow.com/q/9611682/3052438 – Piotr Siupa Jan 24 '22 at 07:49
  • Do you require Windows support other than via Mingw? – rici Jan 25 '22 at 02:02
  • Yes. Windows support is required. I use flex++, bison++ output in visual studio. I can't use yy_scan_string because I can only use flex++ version2.3.8. So I have to convert utf-16 to .l inside. – Ssss Jan 25 '22 at 09:10

0 Answers0