/****************************************************************************** * This program simply writes lines with the alphabet to a file. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ #undef NDEBUG #include "Utils.hpp" #include #include #include #include #include std::locale utf8loc(std::locale(), new std::codecvt_utf8); using namespace Utils; using namespace std; void write_text_file(wstring filespec) { wofstream ofh(filesystem::path(filespec).c_str()); if (!ofh.good()) { throw ios_base::failure(Utils::wchar_to_UTF8(L"Problem opening output file!")); } ofh.imbue(utf8loc); ofh << L"ABCDEFGHIJKLMNOPQRSTUVWXYZ" << endl; ofh << L"ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ" << endl; ofh << L"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ" << endl; ofh << L"゠ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタ" << endl; ofh << L"ダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミ" << endl; ofh << L"ムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ・ーヽヾヿ" << endl; ofh.close(); } int main(int argc, char **argv) { setlocale(LC_ALL, "en_US.UTF-8"); wcout.imbue(utf8loc); wcin.imbue(utf8loc); if (argc != 2) { wcout << L"Syntax: " << Utils::UTF8_to_wstring(argv[0]) << L" {filename}" << endl; exit(1); } wstring const FILESPEC = Utils::UTF8_to_wstring(argv[1]); try { write_text_file(FILESPEC); } catch (ios_base::failure ex) { wcout << L"Error: " << Utils::exceptionMessage(ex) << endl; } catch (...) { wcout << L"Unexpected File Write Error" << endl; } return 0; }