Hello,

My recent patch series provided new implementation for C95 conversion 
functions, but currently they are only used for pre-msvcr80.dll CRTs. I think 
we could move forward to use them for msvcr80.dll and later, and UCRT.

The motivations for this patch series were:

1. Provide replacements for `wctob` and `btowc` functions which have consistent 
behavior with `wcrtomb` and `mbrtowc` functions respectively. (done)
2. Fix return value of `mbrlen` and `mbrtowc` functions when converting from 
DBCS code pages such as 932 (Japanese), 949 (Korean), 936 and 950 (Chinese).

To implement second part for UCRT, we would need to call these functions when 
converting from SBCS or DBCS code pages. However, we cannot use these functions 
to perform conversion from/to UTF-8. Some time ago, I have mentioned in another 
thread that return value of CRT's `mbrlen` and `mbrtowc` is correct when 
converting from UTF-8. This means we can call the replacements when MB_CUR_MAX 
<= 2 (SBCS and DBCS code pages), and call CRT's versions otherwise (I think it 
is safe to assume UTF-8 in case MB_CUR_MAX > 2).

I am not sure what would be a clean way to do it. We need to call `LoadLibrary` 
to obtain UCRT's handle and call `GetProcAddress` to get address of CRTs 
versions so we can call them conditionally. Would it be appropriate to define a 
function with `attribute(constructor)` to achieve this or is there a better 
approach? Also, would it be safe to call `LoadLibrary` from such function?

- Kirill Makurin

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to