17
17
#include < unicode/grapheme_segmenter.h>
18
18
#include < unicode/ucd.h>
19
19
#include < unicode/ucd_enums.h>
20
- #include < unicode/ucd_fmt .h>
20
+ #include < unicode/ucd_ostream .h>
21
21
#include < unicode/utf8_grapheme_segmenter.h>
22
22
23
- #include < fmt/format.h>
24
-
25
23
#include < cassert>
26
24
#include < charconv>
25
+ #include < iomanip>
27
26
#include < iostream>
28
27
#include < optional>
28
+ #include < sstream>
29
29
#include < string>
30
30
31
31
using namespace std ;
@@ -35,16 +35,17 @@ namespace
35
35
36
36
std::string quotedAndEscaped (std::string const & text)
37
37
{
38
- auto result = " \" " s;
38
+ auto result = stringstream {};
39
+ result << ' "' ;
39
40
for (char const ch: text)
40
41
{
41
42
if (std::isprint (ch) && ch != ' "' )
42
- result += ch;
43
+ result << ch;
43
44
else
44
- result += fmt::format ( " \\ x{:02X} " , uint8_t ( ch));
45
+ result << " \\ x" << setw ( 2 ) << std::hex << ( unsigned ( ch) & 0xFF );
45
46
}
46
- result += " \" " ;
47
- return result;
47
+ result << " \" " ;
48
+ return result. str () ;
48
49
}
49
50
50
51
int printUsage (int exitCode)
@@ -86,7 +87,9 @@ vector<char32_t> parseChars(std::string_view text)
86
87
87
88
string prettyAge (unicode::Age age)
88
89
{
89
- string str = fmt::format (" {}" , age);
90
+ // clang-format off
91
+ string str = [=]() { auto s = ostringstream (); s << age; return s.str (); }();
92
+ // clang-format on
90
93
assert (str.at (0 ) == ' V' );
91
94
str = str.substr (1 );
92
95
replace (str.begin (), str.end (), ' _' , ' .' );
@@ -98,20 +101,20 @@ void showCodepointProperties(char32_t codepoint)
98
101
auto const properties = unicode::codepoint_properties::get (codepoint);
99
102
100
103
// clang-format off
101
- cout << fmt::format ( " Name : {} \n " , unicode::codepoint_properties::name (codepoint)) ;
102
- cout << fmt::format ( " Unicode Version : {} \n " , prettyAge (properties.age )) ;
103
- cout << fmt::format ( " Codepoint : U+{:X} \n " , uint32_t (codepoint)) ;
104
- cout << fmt::format ( " UTF-8 : {} \n " , quotedAndEscaped (unicode::convert_to<char >(codepoint))) ;
104
+ cout << " Name : " << unicode::codepoint_properties::name (codepoint) << ' \n ' ;
105
+ cout << " Unicode Version : " << prettyAge (properties.age ) << ' \n ' ;
106
+ cout << " Codepoint : U+" << hex << uint32_t (codepoint) << ' \n ' ;
107
+ cout << " UTF-8 : " << quotedAndEscaped (unicode::convert_to<char >(codepoint)) << ' \n ' ;
105
108
if (properties.general_category != unicode::General_Category::Control)
106
- cout << fmt::format ( " Display : {} \n " , unicode::convert_to<char >(codepoint)) ;
107
- cout << fmt::format ( " Plane : {} \n " , unicode::plane (codepoint)) ;
108
- cout << fmt::format ( " Block : {} \n " , unicode::block (codepoint)) ;
109
- cout << fmt::format ( " Script : {} \n " , unicode::script (codepoint)) ;
110
- cout << fmt::format ( " General Category : {} \n " , properties.general_category ) ;
111
- cout << fmt::format ( " East Asian Width : {} \n " , properties.east_asian_width ) ;
112
- cout << fmt::format ( " Character width : {} \n " , properties.char_width ) ;
113
- cout << fmt::format ( " Emoji Segmentation Category : {} \n " , properties.emoji_segmentation_category ) ;
114
- cout << fmt::format ( " Grapheme Cluster Break : {} \n " , properties.grapheme_cluster_break ) ;
109
+ cout << " Display : " << unicode::convert_to<char >(codepoint) << ' \n ' ;
110
+ cout << " Plane : " << unicode::plane (codepoint) << ' \n ' ;
111
+ cout << " Block : " << unicode::block (codepoint) << ' \n ' ;
112
+ cout << " Script : " << unicode::script (codepoint) << ' \n ' ;
113
+ cout << " General Category : " << properties.general_category << ' \n ' ;
114
+ cout << " East Asian Width : " << properties.east_asian_width << ' \n ' ;
115
+ cout << " Character width : " << properties.char_width << ' \n ' ;
116
+ cout << " Emoji Segmentation Category : " << properties.emoji_segmentation_category << ' \n ' ;
117
+ cout << " Grapheme Cluster Break : " << properties.grapheme_cluster_break << ' \n ' ;
115
118
cout << " \n " ;
116
119
// clang-format off
117
120
}
0 commit comments