Skip to content

Commit 2d31ccc

Browse files
authored
Merge pull request hanickadot#229 from Tudyx/add-documentation-on-unicode
2 parents bb12765 + 22da07b commit 2d31ccc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,28 @@ for (auto match: ctre::range<"([0-9]+),?">(input)) {
254254
}
255255
```
256256

257+
### Unicode
258+
259+
```c++
260+
#include <ctre-unicode.hpp>
261+
#include <iostream>
262+
// needed if you want to output to the terminal
263+
std::string_view cast_from_unicode(std::u8string_view input) noexcept {
264+
return std::string_view(reinterpret_cast<const char *>(input.data()), input.size());
265+
}
266+
int main()
267+
{
268+
using namespace std::literals;
269+
std::u8string_view original = u8"Tu es un génie"sv;
270+
271+
for (auto match : ctre::range<"\\p{Letter}+">(original))
272+
std::cout << cast_from_unicode(match) << std::endl;
273+
return 0;
274+
}
275+
```
276+
277+
[link to compiler explorer](https://godbolt.org/z/erTshe6sz)
278+
257279
## Running tests (for developers)
258280
259281
Just run `make` in root of this project.

0 commit comments

Comments
 (0)