SOL9 Sample: StringTokenizer

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * StringTokenizer.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


#include <sol\StringTokenizer.h>

#include <sol\Locale.h>

void _tmain(int argc, TCHAR* argv[])
{
  Locale locale;

  const TCHAR* string = 
    _T("<html>\n")
    _T("<body>\n")
    _T("<h1>URLEncoder/URLDecoder test!</h1>\n")
    _T("<h2>1234567890</h2>\n")
    _T("<h3>ABCDEFGHIJKLMNOPQRSTUVWXYZ</h3>\n")

    _T("<h3>abcdefghijklmnopqrstuvwxyz</h3>\n")
    _T("<h3>!'#$%&'()=~|0\\`{[]}+*<>?/_</h3>\n")
    //_T("<h3>!\"#$%&'()=~|0\\`{[]}+*<>?/_</h3>\n")

    _T("</body>\n")

    _T("</html>\n");

  _tprintf(_T("String=[%s]\n"), string);

  StringTokenizer tokenizer(string);
  tokenizer.clearSeparator();
  tokenizer.addSeparator((TCHAR)'\n');
  //tokenizer.addSeparator((TCHAR)' ');

  _tprintf(_T("\nCall StringTokenizer::getToken\n"));
  while (tokenizer.hasMoreToken()) {
    String token;

    tokenizer.getToken(token);

    _tprintf(_T("Token=[%s]\n"), (const TCHAR*)token);
  }

  TCHAR* hex = _T("0X0B");
  int n = tokenizer.hexStringToInt(hex);
  _tprintf(_T("Integer=%d\n"), n);

  TCHAR* hex2 = _T("0xff");
  int n2 = tokenizer.hexStringToInt(hex2);
  _tprintf(_T("Integer=%d\n"), n2);

}

Last modified: 2 May 2016

Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.