#include #include #include #include #include #include /* * Fixes Xpdf UTF-8 mess * * Copyright (C) 2020 R.J. van der Putten, Leiden, Holland, * rob at sput dot nl. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ int main(void) { int i, wlen; char line[4096]; wchar_t wlin[4096]; /* Set to UTF-8 */ setlocale(LC_ALL, "C.UTF-8"); i = 0; wlen = 0; memset(line, 0, 4096); memset(wlin, 0, sizeof(wlin)); while (fgets(line, 4096, stdin)) { wlen = mbstowcs(wlin, line, 4095); if (wlen < 0) { printf("%s", line); } else { i = 0; while (i < wlen) { printf("%c", (char) 0xFF & wlin[i]); i++; } } } return(0); }