locale: add UTF8 and ACP/OCP locales
Those are frequently used: - UTF8: for exception message formatting - ACP(OCP): for generic (console) output Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
a5193c9738
commit
2020fa2eec
@ -392,7 +392,7 @@ namespace stdex {
|
|||||||
template<class TR = std::char_traits<char>, class AX = std::allocator<char>>
|
template<class TR = std::char_traits<char>, class AX = std::allocator<char>>
|
||||||
static std::basic_string<char, TR, AX> to_rfc822(_In_ const time_point tp)
|
static std::basic_string<char, TR, AX> to_rfc822(_In_ const time_point tp)
|
||||||
{
|
{
|
||||||
return to_str(tp, "%a, %d %b %Y %H:%M:%S GMT", locale_C.get());
|
return to_str(tp, "%a, %d %b %Y %H:%M:%S GMT", stdex::locale_C);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1999,7 +1999,7 @@ namespace stdex
|
|||||||
{
|
{
|
||||||
size_t n = str.size();
|
size_t n = str.size();
|
||||||
// Use %X instead of %p to ommit leading zeros and save space.
|
// Use %X instead of %p to ommit leading zeros and save space.
|
||||||
stdex::appendf(str, "%c%zX%c", stdex::locale_C.get(), token_tag_start, reinterpret_cast<uintptr_t>(this), token_tag_end);
|
stdex::appendf(str, "%c%zX%c", stdex::locale_C, token_tag_start, reinterpret_cast<uintptr_t>(this), token_tag_end);
|
||||||
return str.size() - n;
|
return str.size() - n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2014,7 +2014,7 @@ namespace stdex
|
|||||||
size_t append_tag(_Inout_ std::basic_string<wchar_t, TR, AX>& str) const
|
size_t append_tag(_Inout_ std::basic_string<wchar_t, TR, AX>& str) const
|
||||||
{
|
{
|
||||||
// Use %X instead of %p to ommit leading zeros and save space.
|
// Use %X instead of %p to ommit leading zeros and save space.
|
||||||
return stdex::appendf(str, L"%c%zX%c", stdex::locale_C.get(), static_cast<wchar_t>(token_tag_start), reinterpret_cast<uintptr_t>(this), static_cast<wchar_t>(token_tag_end));
|
return stdex::appendf(str, L"%c%zX%c", stdex::locale_C, static_cast<wchar_t>(token_tag_start), reinterpret_cast<uintptr_t>(this), static_cast<wchar_t>(token_tag_end));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -89,4 +89,24 @@ namespace stdex
|
|||||||
/// Reusable C-locale
|
/// Reusable C-locale
|
||||||
///
|
///
|
||||||
const inline locale locale_C(create_locale(LC_ALL, "C"));
|
const inline locale locale_C(create_locale(LC_ALL, "C"));
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Reusable UTF-8 locale
|
||||||
|
///
|
||||||
|
const inline locale locale_utf8(create_locale(LC_ALL, ".UTF-8"));
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Reusable default charset locale
|
||||||
|
///
|
||||||
|
const inline locale locale_default(create_locale(LC_ALL,
|
||||||
|
#ifdef WIN32
|
||||||
|
#ifdef _CONSOLE
|
||||||
|
".OCP"
|
||||||
|
#else
|
||||||
|
".ACP"
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
""
|
||||||
|
#endif
|
||||||
|
));
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user