Performs a simple conversion of a narrow character string to a specified character type.
More...
#include <ookii/string_helper.h>
|
| static std::basic_string< CharType, Traits, Alloc > | from_bytes (std::string_view value, const std::locale &loc={}) |
| | Converts a string to the specified character type. More...
|
| |
template<typename CharType, typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
struct ookii::string_convert< CharType, Traits, Alloc >
Performs a simple conversion of a narrow character string to a specified character type.
- Warning
- This method is marginally safer than literal_cast, because it uses the specified locale for the conversion. However, it still works on a per-character basis and will not work correctly on strings containing multi-byte characters.
- Template Parameters
-
| CharType | The character type used. |
| Traits | The character traits to use. Defaults to std::char_traits<CharType>. |
| Alloc | The allocator to use. Defaults to std::allocator<CharType>. |
◆ from_bytes()
template<typename CharType , typename Traits = std::char_traits<CharType>, typename Alloc = std::allocator<CharType>>
| static std::basic_string<CharType, Traits, Alloc> ookii::string_convert< CharType, Traits, Alloc >::from_bytes |
( |
std::string_view |
value, |
|
|
const std::locale & |
loc = {} |
|
) |
| |
|
inlinestatic |
Converts a string to the specified character type.
- Parameters
-
| value | The string to convert. |
| loc | The locale to use to widen the characters. |
- Returns
- The converted string.
The documentation for this struct was generated from the following file:
- /mnt/d/Sven/Documents/Code/Ookii.CommandLine.Cpp/include/ookii/string_helper.h