Lines 27-51
Link Here
|
27 |
|
27 |
|
28 |
namespace enigma |
28 |
namespace enigma |
29 |
{ |
29 |
{ |
30 |
Utf8ToXML::Utf8ToXML(const char * const toTranscode) { |
30 |
Utf8ToXML::Utf8ToXML(const XMLByte * const toTranscode) { |
31 |
init(toTranscode); |
31 |
init(toTranscode); |
32 |
} |
32 |
} |
33 |
|
33 |
|
34 |
Utf8ToXML::Utf8ToXML(const std::string * const toTranscode) { |
34 |
Utf8ToXML::Utf8ToXML(const std::string * const toTranscode) { |
35 |
init(toTranscode->c_str()); |
35 |
init((XMLByte *)toTranscode->c_str()); |
36 |
} |
36 |
} |
37 |
|
37 |
|
38 |
Utf8ToXML::Utf8ToXML(const std::string toTranscode) { |
38 |
Utf8ToXML::Utf8ToXML(const std::string toTranscode) { |
39 |
init(toTranscode.c_str()); |
39 |
init((XMLByte *)toTranscode.c_str()); |
40 |
} |
40 |
} |
41 |
|
41 |
|
42 |
void Utf8ToXML::init(const char * const toTranscode) { |
42 |
void Utf8ToXML::init(const XMLByte * const toTranscode) { |
43 |
unsigned int srcLength = std::strlen(toTranscode) + 1; |
43 |
XMLSize_t srcLength = (XMLSize_t) std::strlen((const char* )toTranscode) + 1; |
44 |
// make safe assumptions on utf-16 size |
44 |
// make safe assumptions on utf-16 size |
45 |
unsigned int maxDestLength = srcLength; |
45 |
XMLSize_t maxDestLength = srcLength; |
46 |
unsigned int charsEaten; |
46 |
XMLSize_t charsEaten; |
47 |
unsigned int destLength; |
47 |
XMLSize_t destLength; |
48 |
unsigned char *charSizes = new unsigned char[maxDestLength]; // just junk |
48 |
XMLByte *charSizes = new XMLByte[maxDestLength]; // just junk |
49 |
// make a buffer - size does not matter - the object is temporary |
49 |
// make a buffer - size does not matter - the object is temporary |
50 |
xmlString = new XMLCh[maxDestLength]; |
50 |
xmlString = new XMLCh[maxDestLength]; |
51 |
// transcode to utf-8 -- there are no unrepresentable chars |
51 |
// transcode to utf-8 -- there are no unrepresentable chars |