Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/p-ranav/unicode_display_width
Displayed width of UTF-8 strings in Modern C++
https://github.com/p-ranav/unicode_display_width
aligned-text alignment cpp11 display display-width length single-header single-header-lib unicode utf8
Last synced: 3 days ago
JSON representation
Displayed width of UTF-8 strings in Modern C++
- Host: GitHub
- URL: https://github.com/p-ranav/unicode_display_width
- Owner: p-ranav
- License: mit
- Created: 2020-05-13T22:50:00.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-02T20:04:23.000Z (almost 2 years ago)
- Last Synced: 2024-05-12T00:03:09.587Z (6 months ago)
- Topics: aligned-text, alignment, cpp11, display, display-width, length, single-header, single-header-lib, unicode, utf8
- Language: C++
- Homepage:
- Size: 498 KB
- Stars: 42
- Watchers: 6
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
Cross-platform single-header library to calculate the display width of UTF-8 strings.
## Quick Start
```cpp
#includeint 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";
}
```