18 #if !defined(XALANUTF8WRITER_HEADER_GUARD_1357924680)
19 #define XALANUTF8WRITER_HEADER_GUARD_1357924680
33 return static_cast<char>((theChar >> 18) & 0x7);
41 return static_cast<char>((theChar >> 12) & 0x3F);
49 return static_cast<char>((theChar >> 12) & 0xF);
57 return static_cast<char>((theChar >> 6) & 0x3f);
65 return static_cast<char>((theChar >> 6) & 0x1f);
73 return static_cast<char>(theChar & 0x3f);
81 return static_cast<char>(0xC0 + theBits);
89 return static_cast<char>(0xE0 + theBits);
97 return static_cast<char>(0xF0 + theBits);
105 return static_cast<char>(0x80 + theBits);
119 MemoryManager& theMemoryManager);
132 assert(m_newlineString != 0);
133 assert(
length(m_newlineString) == m_newlineStringLength);
137 m_newlineStringLength);
142 const XalanDOMChar chars[],
149 return write(chars, start,
length);
158 const XalanDOMChar* data,
161 write(data, theLength);
170 const XalanDOMChar* data,
173 write(data, theLength);
182 const XalanDOMChar* data,
185 write(data, theLength);
190 const XalanDOMChar* theChars,
205 if (theLength >
sizeof(m_buffer))
209 m_writer.write(theChars, 0, theLength);
213 if (m_bufferRemaining < theLength)
220 *m_bufferPosition = theChars[i];
225 m_bufferRemaining -= theLength;
250 assert(theChar < 128);
252 if (m_bufferRemaining == 0)
257 *m_bufferPosition = theChar;
265 const XalanDOMChar* theChars,
270 if (isUTF16HighSurrogate(theChars[i]) ==
false)
272 write(
static_cast<XalanUnicodeChar
>(theChars[i]));
274 else if (i + 1 >= theLength)
276 throwInvalidUTF16SurrogateException(
284 decodeUTF16SurrogatePair(
287 getMemoryManager()));
296 const XalanDOMChar chars[],
300 const XalanDOMChar ch = chars[start];
302 if (isUTF16HighSurrogate(ch) ==
false)
304 write(
static_cast<XalanUnicodeChar
>(ch));
306 else if (start + 1 >=
length)
308 throwInvalidUTF16SurrogateException(
316 decodeUTF16SurrogatePair(
319 getMemoryManager()));
327 const XalanDOMChar* theChars,
332 const XalanDOMChar ch = theChars[i];
334 if (isUTF16HighSurrogate(ch) ==
true)
336 if (i + 1 >= theLength)
338 throwInvalidUTF16SurrogateException(
346 decodeUTF16SurrogatePair(
349 getMemoryManager()));
356 write(
static_cast<XalanUnicodeChar
>(ch));
377 m_writer.write(m_buffer, 0, m_bufferPosition - m_buffer);
379 m_bufferPosition = m_buffer;
380 m_bufferRemaining = kBufferSize;
386 write(XalanUnicodeChar theChar)
390 write(
char(theChar));
392 else if (theChar <= 0x7FF)
394 if (m_bufferRemaining < 2)
404 m_bufferRemaining -= 2;
406 else if (theChar <= 0xFFFF)
409 assert(theChar < 0xD800 || theChar > 0xDBFF);
410 assert(theChar < 0xDC00 || theChar > 0xDFFF);
412 if (m_bufferRemaining < 3)
424 m_bufferRemaining -= 3;
426 else if (theChar <= 0x10FFFF)
428 if (m_bufferRemaining < 4)
442 m_bufferRemaining -= 4;
446 throwInvalidCharacterException(theChar, getMemoryManager());
457 value_type m_buffer[kBufferSize];
459 value_type* m_bufferPosition;
470 #endif // XALANUTF8WRITER_HEADER_GUARD_1357924680