Read a file character by character/UTF8: Difference between revisions
Content added Content deleted
(Add C++ code) |
|||
Line 40: | Line 40: | ||
return EXIT_SUCCESS; |
return EXIT_SUCCESS; |
||
}</lang> |
}</lang> |
||
=={{header|C++}}== |
|||
<lang cpp> |
|||
#include <fstream> |
|||
#include <iostream> |
|||
#include <locale> |
|||
using namespace std; |
|||
int main(void) |
|||
{ |
|||
/* If your native locale doesn't use UTF-8 encoding |
|||
* you need to replace the empty string with a |
|||
* locale like "en_US.utf8" |
|||
*/ |
|||
std::locale::global(std::locale("")); // for C++ |
|||
std::cout.imbue(std::locale()); |
|||
ifstream in("input.txt"); |
|||
wchar_t c; |
|||
while ((c = in.get()) != in.eof()) |
|||
wcout<<c; |
|||
in.close(); |
|||
return EXIT_SUCCESS; |
|||
} |
|||
</lang> |
|||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |