StringFormat2 [ C++] StringUtil Class #pragma once #include class cStringUtil { public: static std::wstring MBSToWCS( const std::string& _ssMbsStr, UINT _nCodePage = CP_UTF8 ); // 유니코드 문자열을 멀티바이트 문자열로 변환 static std::string WCSToMBS( const std::wstring& _ssWcs, UINT _nCodePage = CP_UTF8 ); // Format 함수는 가변 인수를 받아 들여 std::wstring을 포맷합니다. template static std::wstring Format( const std::wstring& format, Args&&... args ) { return std::vf.. 2024. 4. 22. [C++] StringFormat 만들기 C++20 이상: std::format 사용 예시 C++20에서는 std::format이라는 새로운 함수를 도입하여 문자열 포맷팅을 더욱 쉽게 할 수 있게 되었습니다. 이 함수는 Python의 str.format과 유사한 방식으로 작동합니다. 다만, std::format은 컴파일 시간에 포맷 문자열을 검사하여 타입 안전성을 보장합니다. #include #include #include template std::string stringformat(const std::string& format, Args ... args) { size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1; if (size 2024. 3. 4. 이전 1 다음 반응형