p-ranav / unicode_display_width

Displayed width of UTF-8 strings in Modern C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

display_width

Cross-platform single-header library to calculate the display width of UTF-8 strings.

Quick Start

#include <unicode/display_width.hpp>

int main() {
    const std::string input = u8"Hello, world!";
    
    // Calculate display width
    const auto result = unicode::display_width(input);
    
    // Verify result
    std::cout << "Input  : " << input << "\n";
    std::cout << "Output : " << std::string(result, '|') << "\n";
    std::cout << "Width  : " << result << "\n\n";
}

hello_world

About

Displayed width of UTF-8 strings in Modern C++

License:MIT License


Languages

Language:C++ 99.6%Language:CMake 0.4%Language:Shell 0.0%