Attempting to add UTF-8 compatibility with existing configuration files

The first question is for me here, so please bear with me.

I work with some software that uses proprietary configuration files (I think, INI files). These files are loaded when the program starts, and the data is used at runtime. Data can be changed at runtime, and the configuration files themselves are updated when the program is turned off.

We added new language support to our software and ran into a problem. When we give data to these configuration files at runtime that contain non-ASCII characters, the configuration files do not recognize them correctly because they are not compatible with UTF-8.

I tried to change the creation of FILE objects that are populated at startup to use ccs = UTF-8 mode, and I also tried to do _setmode (_fileno (fin), _O_U8TEXT); the call after the FILE stream has been opened, but both attempts cause the following statement:

File: fgets.c
Line: 75

Expression: ( (_Stream->_flag & _IOSTRG) || 
((_textmode_safe(_fileno(_Stream)) == _IOINFO_TM_ANSI) && 
!_tm_unicode_safe(_fileno(_Stream))))

What's even stranger is this statement seems to be related to

_VALIDATE_STREAM_ANSI_SETRET(stream, EINVAL, retval, NULL);

line in fgets.c, which is surrounded by the #ifndef _UNICODE block, and I have _UNICODE defined for my project.

Any understanding of the solution to this problem, so that I can have compatibility with UTF-8 via _setmode or the ccs mode flag, will be appreciated.

Thank.

+3
source share

All Articles