/*
* HTMLEncDec.cpp
* Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
#include <sol\HTMLEncoder.h>
#include <sol\HTMLDecoder.h>
void _tmain(int argc, TCHAR* argv[])
{
const char* string =
"<html>\n"
"<body>\n"
"<h1>URLEncoder/URLDecoder test!</h1>\n"
"<h2>1234567890</h2>\n"
"<h3>ABCDEFGHIJKLMNOPQRSTUVWXYZ</h3>\n"
"<h3>abcdefghijklmnopqrstuvwxyz</h3>\n"
"<h3>!\"#$%&'()=~|0\\`{[]}+*<>?/_</h3>\n"
"</body>\n"
"</html>\n";
printf("String=[%s]\n", string);
// Encoding
HTMLEncoder encoder;
char* encoded = encoder.encode(string);
printf("HTML Encoded1=[%s]\n", encoded);
StringT<char> enc;
encoder.encode(string, enc);
printf("HTML Encoded2=[%s]\n", (const char*)enc);
// Decoding
HTMLDecoder decoder;
char* decoded = decoder.decode(encoded);
printf("HTML Decoded1=[%s]\n", decoded);
StringT<char> dec;
decoder.decode(encoded, dec);
printf("HTML Decoded2=[%s]\n", (const char*)dec);
if (strcmp(string, decoded) ==0) {
printf("OK.HTML-encode and HTML-decode created the same original string \n");
} else {
printf("Failed to HTML-encode or HTML-decode.\n");
}
delete [] encoded;
delete [] decoded;
}
|