diff options
| author | stderr64 <stderr64@null.net> | 2025-10-28 18:11:09 +0200 |
|---|---|---|
| committer | stderr64 <stderr64@null.net> | 2025-10-28 18:11:09 +0200 |
| commit | 557bf9c01fd78848167c1db8327aed259c5b3690 (patch) | |
| tree | e58d1d10861e2586353f3a14193609134314d34f /cpp_unicode_test/stdstring_unicode.cpp | |
| parent | 56346d0b8041caa99ce1ac57becff11e78fd561e (diff) | |
| download | experiments-557bf9c01fd78848167c1db8327aed259c5b3690.tar.gz experiments-557bf9c01fd78848167c1db8327aed259c5b3690.tar.zst | |
Added some stuff
Diffstat (limited to 'cpp_unicode_test/stdstring_unicode.cpp')
| -rw-r--r-- | cpp_unicode_test/stdstring_unicode.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/cpp_unicode_test/stdstring_unicode.cpp b/cpp_unicode_test/stdstring_unicode.cpp new file mode 100644 index 0000000..d60679c --- /dev/null +++ b/cpp_unicode_test/stdstring_unicode.cpp @@ -0,0 +1,33 @@ +#include <cstdlib> +#include <cstdio> +#include <iostream> +#include <fstream> +#include <string> +#include <unistd.h> + +int main( int argc, char *args[] ){ + unsigned char *fcontents = NULL; + std::fstream *charfile = new std::fstream( reinterpret_cast<const char*>("./unicodechars.txt"), std::ios::in ); + if ( charfile->fail() ){ + std::cerr << "Failed to open file\n"; + exit( EXIT_FAILURE ); + } + charfile->seekg( 0, std::ios::end ); + ssize_t fsize = static_cast<ssize_t>(charfile->tellg()); + charfile->seekg( 0, std::ios::beg ); + fcontents = static_cast<unsigned char*>(calloc(fsize, sizeof(unsigned char))); + if ( fcontents == NULL ){ + std::cerr << "calloc failed\n"; + exit( EXIT_FAILURE ); + } + charfile->read( reinterpret_cast<char*>(fcontents), fsize ); + charfile->close(); + delete charfile; + fsize = 0; + std::string *uchars = new std::string( "" ); + uchars->assign( reinterpret_cast<char*>(fcontents) ); + free( fcontents ); + std::cout << uchars->c_str() << "\n"; + delete uchars; + exit( EXIT_SUCCESS ); +} |
