// // main.cpp // valid-utf8 // // Created by Bob Polis at 2019-09-21 // Copyright (c) 2019 SwiftCoder. All rights reserved. // // libcommon #include // UNIX #include #include // C++ #include using namespace std; int main(int argc, const char * argv[]) { int result = EXIT_SUCCESS; try { string text; if (argc == 1) { cin >> text; } else { text = sc::file_get_contents(argv[1]); } result = sc::is_valid_utf8(text) ? EXIT_SUCCESS : EXIT_FAILURE; } catch (const exception& ex) { cerr << basename(const_cast(argv[0])) << ": " << ex.what() << '\n'; result = EXIT_FAILURE; } return result; }