File tree Expand file tree Collapse file tree 5 files changed +21
-10
lines changed Expand file tree Collapse file tree 5 files changed +21
-10
lines changed Original file line number Diff line number Diff line change 1
1
[submodule "third_party/xxHash "]
2
2
path = third_party/xxHash
3
3
url = [email protected] :Cyan4973/xxHash.git
4
+ [submodule "third_party/utfcpp "]
5
+ path = third_party/utfcpp
6
+ url = [email protected] :nemtrif/utfcpp.git
Original file line number Diff line number Diff line change @@ -317,11 +317,8 @@ ecbuild_add_option( FEATURE EXTRA_TESTS
317
317
318
318
### UNICODE support
319
319
320
- check_include_file_cxx ("codecvt" HAVE_CXX_CODECVT )
321
-
322
320
ecbuild_add_option ( FEATURE UNICODE
323
321
DEFAULT ON
324
- CONDITION HAVE_CXX_CODECVT
325
322
DESCRIPTION "Add support for Unicode characters in Yaml/JSON parsers" )
326
323
327
324
### async io support
Original file line number Diff line number Diff line change @@ -763,6 +763,11 @@ if(eckit_HAVE_XXHASH)
763
763
endif ()
764
764
endif ()
765
765
766
+ if (eckit_HAVE_UNICODE )
767
+ set_source_files_properties ( parser/ObjectParser.cc PROPERTIES
768
+ INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR} /third_party/utfcpp/source
769
+ )
770
+ endif ()
766
771
767
772
list ( APPEND eckit_memory_srcs
768
773
memory/Builder.h
Original file line number Diff line number Diff line change 13
13
// / @author Tiago Quintino
14
14
// / @date Jun 2012
15
15
16
+ #include " eckit/parser/ObjectParser.h"
17
+
16
18
#include " eckit/eckit_config.h"
17
19
18
20
#if eckit_HAVE_UNICODE
19
- #include < codecvt>
21
+ #include < iterator>
22
+ #include < string>
23
+
24
+ #include " utf8.h"
20
25
#endif /* eckit_HAVE_UNICODE */
21
26
22
27
#include < locale>
23
28
24
- #include " eckit/parser/ObjectParser.h"
25
29
#include " eckit/utils/Translator.h"
26
30
#include " eckit/value/Value.h"
27
31
@@ -125,9 +129,10 @@ Value ObjectParser::parseNumber() {
125
129
}
126
130
127
131
#if eckit_HAVE_UNICODE
128
- static std::string utf8 (uint32_t code) {
129
- std::wstring_convert<std::codecvt_utf8<char32_t >, char32_t > conv;
130
- return conv.to_bytes (char32_t (code));
132
+ static std::string utf8_to_string (uint32_t code) {
133
+ std::string result;
134
+ utf8::append (code, std::back_inserter (result));
135
+ return result;
131
136
}
132
137
133
138
@@ -151,9 +156,9 @@ std::string ObjectParser::unicode() {
151
156
uint32_t code;
152
157
iss >> std::hex >> code;
153
158
154
- // std::cout << " [" << code << ", " << utf8 (code) << "]" << std::endl;
159
+ // std::cout << " [" << code << ", " << utf8_to_string (code) << "]" << std::endl;
155
160
156
- return utf8 (code);
161
+ return utf8_to_string (code);
157
162
}
158
163
#endif /* eckit_HAVE_UNICODE */
159
164
You can’t perform that action at this time.
0 commit comments