[Bug preprocessor/49973] Column numbers count multibyte characters as multiple columns

joseph at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Tue Sep 17 22:46:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49973

--- Comment #17 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Tue, 17 Sep 2019, lhyatt at gmail dot com wrote:

> In any case, the underlying source of wcwidth() could easily be changed as a
> drop-in replacement so I guess it can also be decided later. The use of
> mbrtowc() is the bigger problem, since this converts from the user's locale and
> it needs to convert from what -finput-charset asked for (or else UTF-8)
> instead.

If __STDC_ISO_10646__ is defined, wchar_t is Unicode and so local code 
converting from UTF-8 to wchar_t can be used (together with wcwidth from 
libc if available).

If __STDC_ISO_10646__ is not defined, the encoding of wchar_t is unknown.  
Maybe in that case it's best to avoid libc's wcwidth (if any) and just use 
a local implementation of wcwidth on the results of converting UTF-8 to 
Unicode code points.


More information about the Gcc-bugs mailing list