1. how do we validate if a name is correct? i mean how do we attempt with zh, zh_CN, zh_CN@xx? using open() to check? what's the fastest and correctest way? 2. Thx for your help, nsz! 2017-01-30 0:37 GMT+08:00 Rich Felker : > On Sun, Jan 29, 2017 at 10:48:34PM +0800, He X wrote: > > btw, with 'p-> to q->', 'strip .UTF-8'(these two in the first thread), > and > > these two patches, fcitx, chromium are working well. > > Can I ask how .UTF-8 got in the locale name to begin with? Did you put > it there, or was it copied from another non-glibc system you logged in > from, or did chromium itself add it? > > Re: the original patch, it should probably (depending on what we want > to do with other invalid encodings) either use strchr to find the > first '.' and strip everything after it, or something like: > > if (loclen > 6 && !strcmp(locname+loclen-6, ".UTF-8")) > > There's no reason to pull strstr in here. > > Rich >