Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Transcoder_Test.cpp

Go to the documentation of this file.
00001 // -*- C++ -*- $Id: Transcoder_Test.cpp,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $
00002 
00003 #include "ACEXML/common/Transcode.h"
00004 #include "ace/Log_Msg.h"
00005 
00006 void dump_utf16 (const ACEXML_UTF16 *data,
00007                  size_t len)
00008 {
00009   size_t ptr = 0;
00010 
00011   while (1)
00012     {
00013       ACE_DEBUG ((LM_DEBUG, "%04x", data[ptr]));
00014 
00015       if (++ptr >= len)
00016         break;
00017 
00018       if (ptr % 4 == 0)
00019         ACE_DEBUG ((LM_DEBUG, "\n"));
00020       else
00021         ACE_DEBUG ((LM_DEBUG, "  "));
00022     }
00023   ACE_DEBUG ((LM_DEBUG, "\n"));
00024   return;
00025 }
00026 
00027 int
00028 ACE_TMAIN (int, ACE_TCHAR*[])
00029 {
00030   ACEXML_UTF16 org [18];
00031 //  =  { 1, 2, 4, 8, 0x10, 0x20, 0x40,
00032 //      0x80,
00033 //      0x100, 0x200, 0x400,
00034 //      0x800, 0x801, 0x802, 0x804, 0x808, 0x810, 0x820,
00035 //      0x840, 0x880, 0x900, 0xa00, 0xc00,
00036 //      0x1000, 0x2000, 0x4000, 0x8000, 0 }
00037   ACEXML_UCS4 temp = 1;
00038 
00039   ACE_OS::memset (org, 0, sizeof org);
00040   size_t x;
00041 
00042   for (x = 0; temp < 0x10000; x++, temp <<= 1)
00043     {
00044       org[x] = ACE_static_cast (ACEXML_UTF16, temp);
00045     }
00046 
00047   ACE_DEBUG ((LM_DEBUG, "Original UTF16 string:\n"));
00048   dump_utf16 (org, x);
00049   ACE_DEBUG ((LM_DEBUG, "\n\n"));
00050 
00051   ACEXML_UTF8 decoded [MAXPATHLEN];
00052   ACE_OS::memset (decoded, 0, sizeof decoded);
00053 
00054   ACEXML_Transcoder::utf16s2utf8s (org, decoded, MAXPATHLEN);
00055 
00056   ACE_DEBUG ((LM_DEBUG, "Transcoded UTF8 string:\n"));
00057   ACE_HEX_DUMP ((LM_DEBUG, decoded, ACE_OS::strlen (decoded) + 1));
00058   ACE_DEBUG ((LM_DEBUG, "\n\n"));
00059 
00060   ACEXML_UTF16 after [18];
00061   ACE_OS::memset (after, 0, sizeof after);
00062   ACEXML_Transcoder::utf8s2utf16s (decoded, after, 18);
00063 
00064   ACE_DEBUG ((LM_DEBUG, "Restored UTF16 string:\n"));
00065   dump_utf16 (after, x);
00066   ACE_DEBUG ((LM_DEBUG, "\n\n"));
00067 
00068   return 0;
00069 }

Generated on Mon Jun 16 13:23:27 2003 for ACEXML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002