Skip to content

Commit

Permalink
[Utils/StrUtils] Disabled Clang's deprecation warning for conversions
Browse files Browse the repository at this point in the history
- std::wstring_convert & std::codecvt_utf8_utf16 are deprecated from C++17 onward
  - A warning is triggered with Emscripten
  • Loading branch information
Razakhel committed Nov 19, 2023
1 parent 267b0e8 commit 8974eb2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/RaZ/Utils/StrUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#ifndef RAZ_STRUTILS_HPP
#define RAZ_STRUTILS_HPP

#include "RaZ/Utils/CompilerUtils.hpp"

#include <algorithm>
#include <cctype>
#include <codecvt>
Expand Down Expand Up @@ -369,7 +371,10 @@ inline std::vector<std::wstring> split(std::wstring text, wchar_t delimiter) {
/// \param text Wide string to convert.
/// \return Converted UTF-8 string.
inline std::string toUtf8(const std::wstring& text) {
PUSH_WARNINGS_STATE
DISABLE_WARNING_CLANG(-Wdeprecated-declarations)
return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>().to_bytes(text);
POP_WARNINGS_STATE
}

/// Returns the current UTF-8 encoded string.
Expand All @@ -384,7 +389,10 @@ constexpr const std::string& toUtf8(const std::string& text) {
/// \param text UTF-8 string to convert.
/// \return Converted wide string.
inline std::wstring toWide(const std::string& text) {
PUSH_WARNINGS_STATE
DISABLE_WARNING_CLANG(-Wdeprecated-declarations)
return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>().from_bytes(text);
POP_WARNINGS_STATE
}

/// Returns the current wide string.
Expand Down

0 comments on commit 8974eb2

Please sign in to comment.