2 NS(XmlGetUtf8InternalEncoding
)(void)
4 return &ns(internal_utf8_encoding
).enc
;
8 NS(XmlGetUtf16InternalEncoding
)(void)
11 return &ns(internal_little2_encoding
).enc
;
12 #elif BYTEORDER == 4321
13 return &ns(internal_big2_encoding
).enc
;
16 return (*(const char *)&n
17 ? &ns(internal_little2_encoding
).enc
18 : &ns(internal_big2_encoding
).enc
);
22 static const ENCODING
* const NS(encodings
)[] = {
23 &ns(latin1_encoding
).enc
,
24 &ns(ascii_encoding
).enc
,
25 &ns(utf8_encoding
).enc
,
26 &ns(big2_encoding
).enc
,
27 &ns(big2_encoding
).enc
,
28 &ns(little2_encoding
).enc
,
29 &ns(utf8_encoding
).enc
/* NO_ENC */
33 NS(initScanProlog
)(const ENCODING
*enc
, const char *ptr
, const char *end
,
34 const char **nextTokPtr
)
36 return initScan(NS(encodings
), (const INIT_ENCODING
*)enc
,
37 XML_PROLOG_STATE
, ptr
, end
, nextTokPtr
);
41 NS(initScanContent
)(const ENCODING
*enc
, const char *ptr
, const char *end
,
42 const char **nextTokPtr
)
44 return initScan(NS(encodings
), (const INIT_ENCODING
*)enc
,
45 XML_CONTENT_STATE
, ptr
, end
, nextTokPtr
);
49 NS(XmlInitEncoding
)(INIT_ENCODING
*p
, const ENCODING
**encPtr
,
52 int i
= getEncodingIndex(name
);
55 SET_INIT_ENC_INDEX(p
, i
);
56 p
->initEnc
.scanners
[XML_PROLOG_STATE
] = NS(initScanProlog
);
57 p
->initEnc
.scanners
[XML_CONTENT_STATE
] = NS(initScanContent
);
58 p
->initEnc
.updatePosition
= initUpdatePosition
;
60 *encPtr
= &(p
->initEnc
);
64 static const ENCODING
*
65 NS(findEncoding
)(const ENCODING
*enc
, const char *ptr
, const char *end
)
67 #define ENCODING_MAX 128
68 char buf
[ENCODING_MAX
];
71 XmlUtf8Convert(enc
, &ptr
, end
, &p
, p
+ ENCODING_MAX
- 1);
75 if (streqci(buf
, KW_UTF_16
) && enc
->minBytesPerChar
== 2)
77 i
= getEncodingIndex(buf
);
80 return NS(encodings
)[i
];
84 NS(XmlParseXmlDecl
)(int isGeneralTextEntity
,
89 const char **versionPtr
,
90 const char **versionEndPtr
,
91 const char **encodingName
,
92 const ENCODING
**encoding
,
95 return doParseXmlDecl(NS(findEncoding
),