how to create/open/save a file as UTF-8 encoding in c++ using ofstream

  • Thread starter Thread starter Midhun jaya
  • Start date Start date
M

Midhun jaya

Guest
i have tried some ways to create a file as utf-8 encoding using ofstream. but some are crashing while running and others are creating ANSI only.

somebody can help me???

i am sharing some examples that i have tried...

of.open("d:/abcdef.txt");

std::locale mylocale("");
of.imbue(mylocale);

of << "some test adasdasdkasldkasldka;sld";

of.close

__________________________________________

std::locale utf8_locale(std::locale(), std::codecvt_utf8_utf16);
of.imbue(utf8_locale);

__________________________________________

locale utfFile("en_US.UTF-8");
of.imbue(utfFile);

____________________________________________

Continue reading...
 
Back
Top