blob: aa96c2dd3175bd8b87cb708c5c47f082ef049a18 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "init.h"
#include <libxml/xmlIO.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/tree.h>
#include <library/cpp/charset/recyr.hh>
#include <util/generic/singleton.h>
namespace {
int CharEncodingInput(unsigned char* out, int* outlen, const unsigned char* in, int* inlen) {
size_t read = 0, written = 0;
RECODE_RESULT r = Recode(CODES_WIN, CODES_UTF8, (const char*)in, (char*)out, (size_t)*inlen, (size_t)*outlen, read, written);
if (r == RECODE_EOOUTPUT)
return -1;
if (r != RECODE_OK)
return -2;
*inlen = (int)read;
*outlen = (int)written;
return (int)written;
}
class TLibXml2 {
public:
inline TLibXml2() {
xmlInitParser();
xmlNewCharEncodingHandler("windows-1251", CharEncodingInput, nullptr);
}
inline ~TLibXml2() {
xmlCleanupParser();
}
};
}
void NXml::InitEngine() {
Singleton<TLibXml2>();
}
|