dbertoni 00/09/27 13:36:43
Modified: c/src/XMLSupport FormatterToXML.cpp FormatterToXML.hpp
Log:
Code to default to UTF-8 if the requested output encoding is not supported.
Revision Changes Path
1.28 +15 -6 xml-xalan/c/src/XMLSupport/FormatterToXML.cpp
Index: FormatterToXML.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToXML.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- FormatterToXML.cpp 2000/09/27 16:39:23 1.27
+++ FormatterToXML.cpp 2000/09/27 20:36:43 1.28
@@ -151,7 +151,17 @@
if (theStream != 0)
{
- theStream->setOutputEncoding(m_encoding);
+ try
+ {
+ theStream->setOutputEncoding(m_encoding);
+ }
+ catch(const
XalanOutputStream::UnsupportedEncodingException&)
+ {
+ // Default to UTF-8 if the requested encoding
is not supported...
+
theStream->setOutputEncoding(s_utf8EncodingString);
+
+ m_encoding = s_utf8EncodingString;
+ }
}
}
@@ -1566,7 +1576,7 @@
static XalanDOMCharVectorType s_asciiEncodingString;
-static XalanDOMCharVectorType s_utf8EncodingString ;
+static XalanDOMString s_utf8EncodingString;
@@ -1598,7 +1608,7 @@
const XalanDOMCharVectorType& FormatterToXML::s_asciiEncodingString =
::s_asciiEncodingString;
-const XalanDOMCharVectorType& FormatterToXML::s_utf8EncodingString =
::s_utf8EncodingString;
+const XalanDOMString&
FormatterToXML::s_utf8EncodingString = ::s_utf8EncodingString;
bool
FormatterToXML::s_javaEncodingIsISO = false;
@@ -1651,8 +1661,7 @@
::s_asciiEncodingString =
MakeXalanDOMCharVector(c_wstr(XALAN_STATIC_UCODE_STRING("ASCII")));
- ::s_utf8EncodingString =
-
MakeXalanDOMCharVector(c_wstr(XALAN_STATIC_UCODE_STRING("UTF-8")));
+ ::s_utf8EncodingString = XALAN_STATIC_UCODE_STRING("UTF-8");
}
@@ -1688,5 +1697,5 @@
XalanDOMCharVectorType().swap(::s_asciiEncodingString);
- XalanDOMCharVectorType().swap(::s_utf8EncodingString);
+ clear(::s_utf8EncodingString);
}
1.17 +3 -3 xml-xalan/c/src/XMLSupport/FormatterToXML.hpp
Index: FormatterToXML.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToXML.hpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- FormatterToXML.hpp 2000/09/05 02:24:49 1.16
+++ FormatterToXML.hpp 2000/09/27 20:36:43 1.17
@@ -586,9 +586,9 @@
const XalanDOMString m_doctypePublic;
/**
- * The character encoding. Not currently used.
+ * The character encoding.
*/
- const XalanDOMString m_encoding;
+ XalanDOMString m_encoding;
/**
* Flag to keep track of the indent amount.
@@ -792,7 +792,7 @@
/**
* The string "UTF-8".
*/
- static const XalanDOMCharVectorType& s_utf8EncodingString;
+ static const XalanDOMString& s_utf8EncodingString;
DOMCharBufferType m_charBuf;