After a lot of searching I start using that weird code:
ofstream myfile; string chars = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя"; myfile.open (&