From d9e04170ac2d8b9b147994a86e045c002d785a79 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 28 Nov 2023 13:36:42 +0100 Subject: [PATCH] unicode: extend charset_from_name Signed-off-by: Simon Rozman --- include/stdex/unicode.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/stdex/unicode.hpp b/include/stdex/unicode.hpp index de11755c1..9abdd7346 100644 --- a/include/stdex/unicode.hpp +++ b/include/stdex/unicode.hpp @@ -62,6 +62,11 @@ namespace stdex constexpr charset_id system_charset = charset_id::system; #endif + /// + /// Parses charset name and returns matching charset code + /// + /// Charset name + /// Charset code or `charset_id::system` if match not found inline charset_id charset_from_name(_In_z_ const char* name) { struct charset_less { @@ -109,6 +114,17 @@ namespace stdex return charset_id::system; } + /// + /// Parses charset name and returns matching charset code + /// + /// Charset name + /// Charset code or `charset_id::system` if match not found + template , class _Alloc = std::allocator> + inline charset_id charset_from_name(_In_ const std::basic_string& name) + { + return charset_from_name(name.c_str()); + } + /// /// Encoding converter context ///