3 #include "ACEXML/common/Transcode.h"
4 #include "ace/Log_Msg.h"
5 #include "ace/OS_NS_string.h"
6 #include "ace/OS_main.h"
8 void dump_utf16 (const ACEXML_UTF16
*data
, size_t len
)
14 ACE_DEBUG ((LM_DEBUG
, "%04x", data
[ptr
]));
20 ACE_DEBUG ((LM_DEBUG
, "\n"));
22 ACE_DEBUG ((LM_DEBUG
, " "));
24 ACE_DEBUG ((LM_DEBUG
, "\n"));
29 ACE_TMAIN (int, ACE_TCHAR
*[])
31 ACEXML_UTF16 org
[18];
32 // = { 1, 2, 4, 8, 0x10, 0x20, 0x40,
34 // 0x100, 0x200, 0x400,
35 // 0x800, 0x801, 0x802, 0x804, 0x808, 0x810, 0x820,
36 // 0x840, 0x880, 0x900, 0xa00, 0xc00,
37 // 0x1000, 0x2000, 0x4000, 0x8000, 0 }
40 ACE_OS::memset (org
, 0, sizeof org
);
43 for (x
= 0; temp
< 0x10000; x
++, temp
<<= 1)
45 org
[x
] = static_cast<ACEXML_UTF16
> (temp
);
48 ACE_DEBUG ((LM_DEBUG
, "Original UTF16 string:\n"));
50 ACE_DEBUG ((LM_DEBUG
, "\n\n"));
52 ACEXML_UTF8 decoded
[MAXPATHLEN
];
53 ACE_OS::memset (decoded
, 0, sizeof decoded
);
55 ACEXML_Transcoder::utf16s2utf8s (org
, decoded
, MAXPATHLEN
);
57 ACE_DEBUG ((LM_DEBUG
, "Transcoded UTF8 string:\n"));
58 ACE_HEX_DUMP ((LM_DEBUG
, decoded
, ACE_OS::strlen (decoded
) + 1));
59 ACE_DEBUG ((LM_DEBUG
, "\n\n"));
61 ACEXML_UTF16 after
[18];
62 ACE_OS::memset (after
, 0, sizeof after
);
63 ACEXML_Transcoder::utf8s2utf16s (decoded
, after
, 18);
65 ACE_DEBUG ((LM_DEBUG
, "Restored UTF16 string:\n"));
66 dump_utf16 (after
, x
);
67 ACE_DEBUG ((LM_DEBUG
, "\n\n"));