J
J
jonasas2015-08-27 14:59:26
C++ / C#
jonasas, 2015-08-27 14:59:26

How to convert KOI8 to UTF in C/C++?

From other encodings (CP1251 etc) I convert with boost::locale::conv::to_utf .
For such encodings, boost recommends boost::locale::util::base_converter ( here ).
I still haven't figured out how to use it. There is a short help on converting to unicode, but I don't understand how to work with it.
Perhaps there are other options (without boost), but I would not want to pull another unwieldy library.
Help me please!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mirilaczvili, 2015-08-27
@2ord

Libiconv?

A
AxisPod, 2015-08-28
@AxisPod

Why would you even use util. Use exactly to_utf, doesn't boost support koi8? See if the locale you need is in the system, if not, you need to generate it. Why do you not like the option

generator gen;
std::locale loc= gen().generate("ru_RU.koi8-r");
std::string utf8_string = to_utf<char>(koi8_string, loc);

It may be necessary to adjust the generator unless.
PS Fixed the name of the locale.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question