1 Screenshot
2 Source code
/*
* String.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2009/10/22
// 2009/11/12
#pragma once
#include <sol/String.h>
#include <sol/Locale.h>
void _tmain(int argc, TCHAR** argv)
{
Locale locale; //In fact, this is a call '_tsetlocale(LC_ALL, _T(""))';
//String concatination with char and wchar_t strings;
String a(_T("http"));
a = a + _T("://");
a = a + _T("www.antillia.com:");
a = a + 80;
a = a + _T("/index.html");
_tprintf(_T("1 %s\n"), (const TCHAR*)a);
String b(_T("10.0/3.0"));
b = b + _T("=");
b = b + float(10.0/3.0);
b = b + " こんちは ";
b = b + " 世界 ";
b = b + _T(" さようなら ");
b = b + _T(" 世界 ");
_tprintf(_T("2 %s\n"), (const TCHAR*)b);
String string = "This is your destiny.";
string = string + _T(" Use your power. ");
string = string + " Global Warming Crisis Reality.";
_tprintf(_T("3 %s\n"), (const TCHAR*)string);
//startsWith, endsWith, findFirst, findLast
String fileName = _T("c:\\Program Files\\Sample\\Antillia\\Application\\Sample\\Sample.cpp");
String folder = _T("C:\\program files");
String ext = _T(".Cpp");
if (fileName.startsWith((const TCHAR*)folder)) {
_tprintf(_T("%s startsWith %s\n"), (const TCHAR*)fileName, (const TCHAR*)folder);
} else {
_tprintf(_T("%s doesn't start With %s\n"), (const TCHAR*)fileName, (const TCHAR*)folder);
}
if (fileName.startsWithIgnoreCase((const TCHAR*)folder)) {
_tprintf(_T("%s startsWithIgnoreCase %s\n"), (const TCHAR*)fileName, (const TCHAR*)folder);
} else {
_tprintf(_T("%s doesn't start WithIgnoreCase %s\n"), (const TCHAR*)fileName, (const TCHAR*)folder);
}
if (fileName.endsWith((const TCHAR*)ext)) {
_tprintf(_T("%s endsWith %s\n"), (const TCHAR*)fileName, (const TCHAR*)ext);
} else {
_tprintf(_T("%s doesn't end With %s\n"), (const TCHAR*)fileName, (const TCHAR*)ext);
}
if (fileName.endsWithIgnoreCase((const TCHAR*)ext)) {
_tprintf(_T("%s endsWithIgnoreCase %s\n"), (const TCHAR*)fileName, (const TCHAR*)ext);
} else {
_tprintf(_T("%s doesn't end WithIgnoreCase %s\n"), (const TCHAR*)fileName, (const TCHAR*)ext);
}
const TCHAR* sampleBS = _T("Sample\\");
//findLast
const TCHAR* sample = fileName.findLast(sampleBS);
if (sample) {
_tprintf(_T("%s findLast %s from target:%s\n"), (const TCHAR*)sampleBS,
sample, (const TCHAR*)fileName);
}
//findFirst
const TCHAR* sampleFirst = fileName.findFirst(sampleBS);
if (sampleFirst) {
_tprintf(_T("%s findFirst %s from target:%s\n"), (const TCHAR*)sampleBS,
sampleFirst, (const TCHAR*)fileName);
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.