wstring _Messages_impl::do_get(catalog thecat, int set, int p_id, const wstring& dfault) const { typedef ctype<wchar_t> wctype; const wctype& ct = use_facet<wctype>(_M_map->lookup(thecat)); const char* str = _Locale_catgets(_M_message_obj, thecat, set, p_id, ""); // Verify that the lookup failed; an empty string might represent success. if (!str) return dfault; else if (str[0] == '\0') { const char* str2 = _Locale_catgets(_M_message_obj, thecat, set, p_id, "*"); if (!str2 || strcmp(str2, "*") == 0) return dfault; } // str is correct. Now we must widen it to get a wstring. size_t n = strlen(str); // NOT PORTABLE. What we're doing relies on internal details of the // string implementation. (Contiguity of string elements.) wstring result(n, wchar_t(0)); ct.widen(str, str + n, &*result.begin()); return result; }
string messages<char>::do_get(catalog cat, int set, int p_id, const string& dfault) const { return _M_message_obj != 0 && cat >= 0 ? string(_Locale_catgets(_M_message_obj, cat, set, p_id, dfault.c_str())) : dfault; }