Am Sonntag, 3. September 2006 16:18 schrieb Abdelrazak Younes: > Georg Baum wrote: > > Am Sonntag, 3. September 2006 15:56 schrieb Abdelrazak Younes: > >> Georg Baum wrote: > >>> Am Sonntag, 3. September 2006 15:30 schrieb Abdelrazak Younes: > >>>> Question first: std::tolower() is a template and compiles fine with > >>>> char_type. > >>> ??? std::tolower comes from the C library (ctype.h) and is defined like > >>> this: > >>> > >>> int tolower(int); > >> MSVC doc says: > >> > >> Converts a character to upper case. > >> > >> > >> template<Class CharType> > >> CharType toupper( > >> CharType _Ch, > >> const locale& _Loc > >> ) > > > > That is a different beast with two arguments ;-) > > Ah? I thought the second one has a default english locale.
No. "int std::tolower(int c)" is a separate function inherited from C. There is also a "wint_t towlower(wint_t wc)". > > Maybe we could use this > > instead with a suitable locale. > > Yes but I guess this wouldn't work with full unicode. Arabic for example > has a notion of uppercase (kind-off). AFAIU this wouldn't be enough for > language like German which could need two chars for a different case. > > How do we know which locale we are in? Some global functions? We can always get the global locale with std::locale global; Note that this is the C++ locale (as used by the template function above). C has also locales (used by the 1 argument function above) that can be queried by the LC_* environment variables. Confusing, isnt it? But: I am not sure, but I believe that our lowercase/uppercase functions only operate on document contents, so we are not interested in the global locale, but in a locale that works with the document language. This locale stuff is quite complicated. If you don't have a recent printing of stroustrup you can also read the relevant appendix D online: http://www.research.att.com/~bs/3rd_loc0.html Georg
