Print this page
3154 Nonconforming tolower and toupper with UTF-8 locales


 144 
 145 static char     *widemsg;
 146 
 147 void
 148 werr(const char *fmt, ...)
 149 {
 150         char    *msg;
 151 
 152         va_list va;
 153         va_start(va, fmt);
 154         (void) vasprintf(&msg, fmt, va);
 155         va_end(va);
 156 
 157         free(widemsg);
 158         widemsg = msg;
 159 }
 160 
 161 /*
 162  * This is used for 8-bit encodings.
 163  */

 164 int
 165 towide_none(wchar_t *c, const char *mb, unsigned n)
 166 {
 167         _NOTE(ARGUNUSED(n));
 168 
 169         if (mb_cur_max != 1) {
 170                 werr("invalid or unsupported multibyte locale");
 171                 return (-1);
 172         }
 173         *c = (uint8_t)*mb;
 174         return (1);
 175 }
 176 
 177 int
 178 tomb_none(char *mb, wchar_t wc)
 179 {
 180         if (mb_cur_max != 1) {
 181                 werr("invalid or unsupported multibyte locale");
 182                 return (-1);
 183         }




 144 
 145 static char     *widemsg;
 146 
 147 void
 148 werr(const char *fmt, ...)
 149 {
 150         char    *msg;
 151 
 152         va_list va;
 153         va_start(va, fmt);
 154         (void) vasprintf(&msg, fmt, va);
 155         va_end(va);
 156 
 157         free(widemsg);
 158         widemsg = msg;
 159 }
 160 
 161 /*
 162  * This is used for 8-bit encodings.
 163  */
 164 /* ARGSUSED */
 165 int
 166 towide_none(wchar_t *c, const char *mb, unsigned n)
 167 {
 168         _NOTE(ARGUNUSED(n));
 169 
 170         if (mb_cur_max != 1) {
 171                 werr("invalid or unsupported multibyte locale");
 172                 return (-1);
 173         }
 174         *c = (uint8_t)*mb;
 175         return (1);
 176 }
 177 
 178 int
 179 tomb_none(char *mb, wchar_t wc)
 180 {
 181         if (mb_cur_max != 1) {
 182                 werr("invalid or unsupported multibyte locale");
 183                 return (-1);
 184         }