1 Screenshot
2 Source code
/*
* HTMLEncDec.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// 2012/03/10 Updated.
#include <sol\HTMLEncoder.h>
#include <sol\HTMLDecoder.h>
#include <sol/Locale.h>
void _tmain(int argc, TCHAR* argv[])
{
//2012/03/10
Locale locale;
const char* string =
"<html>\n"
"<body>\n"
"<h1>HTMLEncoder/HTMLDecoder 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;
//2012/03/10
const String bstring = string;
String bencoded = encoder.encode(bstring);
_tprintf(_T("String Encoded = %s\n"), (const TCHAR*)bencoded);
String bdecoded = decoder.decode(bencoded);
_tprintf(_T("String Decoded = %s\n"), (const TCHAR*)bdecoded);
const WString wstring =
L"<html>\n"
L"<body>\n"
L"<h1>WString HTMLEncoder/HTMLDecoder test!</h1>\n"
L"<h2>こんにちは</h2>\n" //Japanese text
L"<h2>1234567890</h2>\n"
L"<h3>ABCDEFGHIJKLMNOPQRSTUVWXYZ</h3>\n"
L"<h3>abcdefghijklmnopqrstuvwxyz</h3>\n"
L"<h3>!\"#$%&'()=~|0\\`{[]}+*<>?/_</h3>\n"
L"<h3>これは日本語です</h3>\n" //Japanese text
L"</body>\n"
L"</html>\n";;
WString wencoded = encoder.encode(wstring);
printf("WString Encoded = %S\n", (const wchar_t*)wencoded);
WString wdecoded = decoder.decode(wencoded);
printf("WString Decoded = %S\n", (const wchar_t*)wdecoded);
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.