diff --git a/include/stdex/sgml.hpp b/include/stdex/sgml.hpp index 24a8b2248..bf216e4a7 100644 --- a/include/stdex/sgml.hpp +++ b/include/stdex/sgml.hpp @@ -358,6 +358,26 @@ namespace stdex sgml2wstrcat(dst, src, count_src, skip, offset, map); } + /// + /// Convert SGML string to Unicode (UTF-16 on Windows) + /// + /// \param[inout] dst String to write Unicode to + /// \param[in] src SGML string + /// \param[in] skip Bitwise flag of stdex::sgml_* constants that list SGML entities to skip converting + /// \param[in] offset Logical starting offset of source and destination strings. Unused when map parameter is nullptr. + /// \param[out] map The vector to write index mapping between source and destination string to. + /// + template + inline void sgml2wstrcpy( + _Inout_ std::wstring& dst, + _In_ const std::basic_string<_Elem, _Traits, _Ax>& src, + _In_ int skip = 0, + _In_ const mapping& offset = mapping(0, 0), + _Inout_opt_ mapping_vector* map = nullptr) + { + sgml2wstrcpy(dst, src.data(), src.size(), skip, offset, map); + } + /// /// Convert SGML string to Unicode (UTF-16 on Windows) /// @@ -384,7 +404,7 @@ namespace stdex dst[0] = 0; if (map) map->clear(); - sgml2wstrcat(dst, count_dst, src, count_src, skip, offset, map); + return sgml2wstrcat(dst, count_dst, src, count_src, skip, offset, map); } /// @@ -750,6 +770,21 @@ namespace stdex wstr2sgmlcat(dst, src, count_src, what); } + /// + /// Convert Unicode string (UTF-16 on Windows) to SGML + /// + /// \param[inout] dst String to write SGML to + /// \param[in] src Unicode string + /// \param[in] what Bitwise flag of stdex::sgml_* constants that force extra characters otherwise not converted to SGML + /// + inline void wstr2sgmlcpy( + _Inout_ std::string& dst, + _In_ const std::wstring& src, + _In_ size_t what = 0) + { + wstr2sgmlcpy(dst, src.data(), src.size(), what); + } + /// /// Convert Unicode string (UTF-16 on Windows) to SGML /// @@ -769,7 +804,7 @@ namespace stdex assert(dst || !count_dst); if (count_dst) dst[0] = 0; - wstr2sgmlcat(dst, count_dst, src, count_src, what); + return wstr2sgmlcat(dst, count_dst, src, count_src, what); } /// diff --git a/include/stdex/unicode.hpp b/include/stdex/unicode.hpp index fd972d0dc..fd981b100 100644 --- a/include/stdex/unicode.hpp +++ b/include/stdex/unicode.hpp @@ -280,7 +280,7 @@ namespace stdex _In_ charset_id charset = charset_id::default) { std::string dst; - wstr2str(dst, src, count_src, charset); + strcat(dst, src, count_src, charset); return dst; }