u5e
UnicodeTextC++Library
normalization_form_d.cpp
1 /**
2  * \page normalization_form_d Example: Normalize a utf8 string in form D
3  *
4  * This example covers the usage of u5e::filter with
5  * u5e::normalization_form_d in order to normalize a utf8 string.
6  *
7  * \code
8  */// Example on how to iterate
9 
10 #include <u5e/utf8_string.hpp>
11 #include <u5e/filter.hpp>
12 #include <u5e/normalization_form_d.hpp>
13 #include <stdio.h>
14 
15 int main(int argc, char **argv) {
16 
17  // for each argument
18  for (int i = 1; i < argc; i++) {
19 
20  // get a utf8_string_view
21  u5e::utf8_string input(argv[i]);
22  u5e::utf8_string output;
25 
26  // print out the codepoints
27  for (u5e::utf8_string::const_iterator it = output.codepoint_cbegin();
28  it != output.codepoint_cend(); it++ ) {
29  // the value dereferenced is the codepoint, not octets even if
30  // the original text had "wide" chars.
31  printf(" U+%06llx", (long long unsigned int)*it);
32  }
33 
34  printf("\n");
35  }
36  return 0;
37 }
38 /**
39  * \endcode
40  */
main u5e namespace
utf8_const_iterator operator++(int junk)
int filter(InputIteratorType input_from, InputIteratorType input_to, OutputType &output, Functor operation)
Walks an input iterator through a filter.
Definition: filter.hpp:46
basic_encodedstring(const NativeString &s)
int normalization_form_d(basic_grapheme< InputStorageType > grapheme, OutputStorageType &output)
u5e::filter algorithm for normalizing graphemes
basic_grapheme_iterator< basic_encodedstring > grapheme_end()
bool operator!=(const utf8_const_iterator &rhs) const
const codepoint operator*()
basic_grapheme_iterator< basic_encodedstring > grapheme_begin()
basic_encodedstring< utf8, std::string > utf8_string
A basic_encodedstring of utf8 and std::string.
Definition: utf8_string.hpp:19