Author: carnold
Date: Tue Nov 20 16:27:21 2007
New Revision: 596890

URL: http://svn.apache.org/viewvc?rev=596890&view=rev
Log:
LOGCXX-85: Mac OS/X wchar_support

Modified:
    logging/log4cxx/trunk/src/main/cpp/charsetdecoder.cpp
    logging/log4cxx/trunk/src/main/cpp/charsetencoder.cpp
    logging/log4cxx/trunk/src/main/cpp/unicodehelper.cpp

Modified: logging/log4cxx/trunk/src/main/cpp/charsetdecoder.cpp
URL: 
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/charsetdecoder.cpp?rev=596890&r1=596889&r2=596890&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/charsetdecoder.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/charsetdecoder.cpp Tue Nov 20 16:27:21 
2007
@@ -424,7 +424,7 @@
                std::string encoding;
           };
 
-#if LOG4CXX_LOGCHAR_IS_UTF8 && LOG4CXX_HAS_WCHAR_T && (defined(_WIN32) || 
defined(__STDC_ISO_10646__))
+#if LOG4CXX_LOGCHAR_IS_UTF8 && LOG4CXX_HAS_WCHAR_T && (defined(_WIN32) || 
defined(__STDC_ISO_10646__) || defined(__APPLE__))
           /**
           *    Decoder to convert array of wchar_t to UTF-8 bytes.
           *
@@ -462,7 +462,7 @@
                   out.reserve(out.length() + in.remaining()/sizeof(wchar_t));
                   char utf8[8];
                   while(src < srcEnd) {
-#if defined(__STDC_ISO_10646__)                  
+#if defined(__STDC_ISO_10646__) || defined(__APPLE__)                  
                       unsigned int sv = *(src++);
 #else
                                  unsigned int sv = decodeWide(src, srcEnd);
@@ -570,7 +570,7 @@
 CharsetDecoder* CharsetDecoder::createWideDecoder() {
 #if LOG4CXX_LOGCHAR_IS_WCHAR
   return new TrivialCharsetDecoder();
-#elif defined(_WIN32) || defined(__STDC_ISO_10646__)
+#elif defined(_WIN32) || defined(__STDC_ISO_10646__) || defined(__APPLE__)
   return new WideToUTF8CharsetDecoder();
 #else
   return new APRCharsetDecoder("WCHAR_T");

Modified: logging/log4cxx/trunk/src/main/cpp/charsetencoder.cpp
URL: 
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/charsetencoder.cpp?rev=596890&r1=596889&r2=596890&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/charsetencoder.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/charsetencoder.cpp Tue Nov 20 16:27:21 
2007
@@ -283,7 +283,7 @@
 #endif
 
 #if LOG4CXX_LOGCHAR_IS_WCHAR
-#if defined(_WIN32) || defined(__STDC_ISO_10646__)
+#if defined(_WIN32) || defined(__STDC_ISO_10646__) || defined(__APPLE__)
           /**
          *  Converts a wstring to UTF-8.
           */
@@ -333,14 +333,14 @@
                        return 0xFFFF;
                                  }
 #endif
-#if defined(__STDC_ISO_10646__)
+#if defined(__STDC_ISO_10646__) || defined(__APPLE__)
                   unsigned int decodeWide(const wchar_t*& src, const wchar_t* 
/* srcEnd */) {
                                                return *(src++);
                                  }
 #endif
           };
 #else
-#error logchar cannot be wchar_t unless _WIN32 or __STDC_ISO_10646___ is 
defined          
+#error logchar cannot be wchar_t unless _WIN32, __STDC_ISO_10646___ or 
__APPLE__ is defined          
 #endif
 #endif
 
@@ -405,7 +405,7 @@
                   UTF16LECharsetEncoder& operator=(const 
UTF16LECharsetEncoder&);
           };
 
-#if LOG4CXX_LOGCHAR_IS_UTF8 && (defined(_WIN32) || defined(__STDC_ISO_10646__))
+#if LOG4CXX_LOGCHAR_IS_UTF8 && (defined(_WIN32) || defined(__STDC_ISO_10646__) 
|| defined(__APPLE__))
 
           /**
           *   Converts a LogString to an array of wchar_t.
@@ -453,7 +453,7 @@
                                        }
 #endif
 
-#if defined(__STDC_ISO_10646__)
+#if defined(__STDC_ISO_10646__) || defined(__APPLE__)
                                    int encodeWide(unsigned int ch, wchar_t* 
dst) {
                                                *dst = ch;
                                                return 1;
@@ -579,12 +579,16 @@
 }
 #endif
 
+CharsetEncoderPtr CharsetEncoder::getUTF8Encoder() {
+    return new UTF8CharsetEncoder();
+}
+
 
 #if LOG4CXX_HAS_WCHAR_T
 CharsetEncoder* CharsetEncoder::createWideEncoder() {
 #if LOG4CXX_LOGCHAR_IS_WCHAR
   return new TrivialCharsetEncoder();
-#elif LOG4CXX_LOGCHAR_IS_UTF8 && (defined(_WIN32) || 
defined(__STDC_ISO_10646__))
+#elif LOG4CXX_LOGCHAR_IS_UTF8 && (defined(_WIN32) || 
defined(__STDC_ISO_10646__) || defined(__APPLE__))
   return new WideCharsetEncoder();
 #else
   return new APRCharsetEncoder("WCHAR_T");

Modified: logging/log4cxx/trunk/src/main/cpp/unicodehelper.cpp
URL: 
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/unicodehelper.cpp?rev=596890&r1=596889&r2=596890&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/unicodehelper.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/unicodehelper.cpp Tue Nov 20 16:27:21 
2007
@@ -165,7 +165,7 @@
 #if LOG4CXX_LOGCHAR_IS_WCHAR
 unsigned int UnicodeHelper::decode(const LogString& in, 
LogString::const_iterator& iter) {
     const wchar_t* src = in.data() + (iter - in.begin());
-#if defined(__STDC_ISO_10646__)
+#if defined(__STDC_ISO_10646__) || defined(__APPLE__)
     unsigned int sv = *(src++);
 #elif defined(_WIN32)
     const wchar_t* srcEnd = in.data() + in.length();
@@ -181,7 +181,7 @@
         }
     }
 #else
-#error logchar cannot be wchar_t unless _WIN32 or __STDC_ISO_10646__ is defined
+#error logchar cannot be wchar_t unless _WIN32, __STDC_ISO_10646__ or 
__APPLE__ is defined
 #endif
     iter = in.begin() + (src - in.data());
     return sv;
@@ -215,13 +215,13 @@
   dst[1] = ls;
   return 2;
 }
-#elif defined(__STDC_ISO_10646__)
+#elif defined(__STDC_ISO_10646__) || defined(__APPLE__)
 int UnicodeHelper::encode(unsigned int ch, logchar* dst) {
    *dst = ch;
    return 1;
 }
 #else
-#error logchar cannot be wchar_t unless _WIN32 or __STDC_ISO_10646__ is defined
+#error logchar cannot be wchar_t unless _WIN32, __STDC_ISO_10646__ or 
__APPLE__ is defined
 #endif
 #endif
 


Reply via email to