std::vprint_unicode

std::vprint_unicode (유니코드 형식 문자열 출력)

형식 문자열 fmt에 따라 args를 형식화하고 결과를 출력 스트림에 쓰는 함수예요. 유니코드 문자에 대해 안전하게 출력해요. C++23부터 있어요.

출처: cppreference

본문

<print> 헤더에 정의돼 있어요.

// (1) C++23
void vprint_unicode( std::FILE* stream,
                     std::string_view fmt, std::format_args args );

// (2) C++23
void vprint_unicode_buffered( std::FILE* stream,
                              std::string_view fmt, std::format_args args );

// (3) C++23
void vprint_unicode_buffered( std::string_view fmt, std::format_args args );

형식 문자열 fmt에 따라 args를 형식화하고 결과를 출력 스트림에 써요.

    1. 다음 연산을 순서대로 수행해요: 스트림을 잠그고(lock), UTF-8로 정확한 출력을 위해 문자 검증을 수행하고, 형식화된 결과를 써요. 유니코드 문자가 터미널에서 정확히 표시되도록 보장해요.
  • 2,3) 버퍼링된 변형으로, 형식화된 결과를 버퍼에 모았다가 한 번에 써요.

vprint_unicodestd::print·std::println의 저수준 변형으로, 미리 형식화된 std::format_args를 받아요.

예제

#include <print>
#include <format>

int main()
{
    std::vprint_unicode(stdout, "Hello, {}", std::make_format_args("world"));
    // "Hello, world"
}

더 알아보기 (Learn more)

cppreference