diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2008-03-04 13:56:48 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2008-03-04 13:56:48 +0000 |
commit | c4078c377d74290ebe4e66da0b4975da91732376 (patch) | |
tree | 1816ef391e42a07929304908ac0e21f4c2f6cb7b /ACE/ace/UTF8_Encoding_Converter.cpp | |
parent | 700d1c1a6be348c6c70a2085e559baeb8f4a62ea (diff) | |
download | ATCD-c4078c377d74290ebe4e66da0b4975da91732376.tar.gz |
swap in externals for ACE and TAO
Diffstat (limited to 'ACE/ace/UTF8_Encoding_Converter.cpp')
-rw-r--r-- | ACE/ace/UTF8_Encoding_Converter.cpp | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/ACE/ace/UTF8_Encoding_Converter.cpp b/ACE/ace/UTF8_Encoding_Converter.cpp deleted file mode 100644 index 0a6ee6e54f5..00000000000 --- a/ACE/ace/UTF8_Encoding_Converter.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// $Id$ - -#include "ace/UTF8_Encoding_Converter.h" - -#if defined (ACE_USES_WCHAR) -#include "ace/UTF16_Encoding_Converter.h" -#include "ace/UTF32_Encoding_Converter.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_Memory.h" - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_UTF8_Encoding_Converter::ACE_UTF8_Encoding_Converter (void) - : native_ (0) -{ - // Choose a converter for the ASCII or UTF-8 string to a wide character - // string which we will use in from_utf8. We have to make an - // assumption here about the encoding based on the size of ACE_TCHAR. - switch (sizeof (ACE_TCHAR)) - { - case 4: - ACE_NEW(this->native_, ACE_UTF32_Encoding_Converter); - break; - case 2: - ACE_NEW(this->native_, ACE_UTF16_Encoding_Converter); - break; - } -} - -ACE_UTF8_Encoding_Converter::~ACE_UTF8_Encoding_Converter (void) -{ - delete native_; -} - -ACE_UTF8_Encoding_Converter::Result -ACE_UTF8_Encoding_Converter::to_utf8 (const void* source, - size_t source_size, - ACE_Byte* target, - size_t target_size, - bool /*strict*/) -{ - if (target_size >= source_size) - { - ACE_OS::memcpy (target, source, source_size); - return CONVERSION_OK; - } - - return TARGET_EXHAUSTED; -} - -ACE_UTF8_Encoding_Converter::Result -ACE_UTF8_Encoding_Converter::from_utf8 (const ACE_Byte* source, - size_t source_size, - void* target, - size_t target_size, - bool strict) -{ - if (this->native_ != 0) - { - return this->native_->from_utf8(source, source_size, - target, target_size, strict); - } - - ACE_TCHAR* targetStart = static_cast<ACE_TCHAR*> (target); - ACE_OS::strncpy (targetStart, - ACE_TEXT_CHAR_TO_TCHAR ( - reinterpret_cast<const char*> (source)), - source_size); - targetStart[source_size] = 0; - return CONVERSION_OK; -} - -ACE_UTF8_Encoding_Converter* -ACE_UTF8_Encoding_Converter::encoded (const ACE_Byte* source, - size_t source_size) -{ - for(size_t i = 0; i < source_size; i++) - { - if (source[i] < 0x01 || source[i] > 0x7f) - return 0; - } - - // All characters are "valid" ASCII - ACE_UTF8_Encoding_Converter* converter = 0; - ACE_NEW_RETURN (converter, - ACE_UTF8_Encoding_Converter, - 0); - return converter; -} - -ACE_END_VERSIONED_NAMESPACE_DECL -#endif /* ACE_USES_WCHAR */ |