on-internet
← Community

How to handle values greater than 255 as returned by toupper() in recent macOS with UTF-8 locales

Stack Overflow ·

The problem, the code below is trying to address, is on how to effectively detect that an UTF-8 based locale might be in use so that all code points above 127 are not queried for ctype attributes, as we are dealing with plain (not wide) chars. At least in macOS 14, when using an UTF-8 based locale. the following program will show 2 problematic code points that eventhough are valid for an unsigned char, are getting as a response from toupper() values that are not able to fit on that type: #include <langinfo.h> #include <ctype.h> #include <locale.h> #include <stdlib.h> #include <string.h> #inclu

Comments

Sign in or sign up to comment and upvote.

No comments yet.