Files
winix/templates/filters.cpp
Tomasz Sowa 8c01b0f6c0 added: two tables to locales/substitute: smallleters, capitalics
added: locale.ToSmall(wchar_t), locale.ToCapital(wchar_t)
       now we are able to recognize other than ASCII characters
added: static/basic/winix.css with basic styles
removed: [include "item_options.html"] from html templates (fun_cat.html and others)




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@760 e52654a7-88a9-db11-a3e9-0013d4bc506e
2011-08-29 22:23:54 +00:00

81 lines
1.2 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
#include "templates.h"
#include "core/misc.h"
namespace TemplatesFunctions
{
static std::string urlencode_tmp;
static std::string qencode_tmp;
void fil_urlencode(Info & i)
{
UrlEncode(i.in.Str(), urlencode_tmp);
i.out << R(urlencode_tmp);
}
void fil_qencode(Info & i)
{
QEncode(i.in.Str(), qencode_tmp);
i.out << R(qencode_tmp);
}
void fil_capitalize(Info & i)
{
const std::wstring & str = i.in.Str();
for(size_t a=0 ; a<str.size() ; ++a)
i.out << R(locale.ToCapital(str[a]));
}
void fil_tosmall(Info & i)
{
const std::wstring & str = i.in.Str();
for(size_t a=0 ; a<str.size() ; ++a)
i.out << R(locale.ToSmall(str[a]));
}
// a first letter in a sentence will be capitalized
void fil_firstup(Info & i)
{
bool was_dot = true;
const std::wstring & str = i.in.Str();
for(size_t a=0 ; a<str.size() ; ++a)
{
if( was_dot )
{
if( str[a]!=' ' && str[a]!='\t' && str[a]!=13 && str[a]!=10 && str[a]!=160 )
was_dot = false;
i.out << R(locale.ToCapital(str[a]));
}
else
{
i.out << R(str[a]);
}
if( str[a] == '.' )
was_dot = true;
}
}
} // namespace