2011-01-26 13:45:38 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2011-08-30 00:23:54 +02:00
|
|
|
* Copyright (c) 2008-2011, Tomasz Sowa
|
2011-01-26 13:45:38 +01:00
|
|
|
* 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)
|
2011-08-30 00:23:54 +02:00
|
|
|
i.out << R(locale.ToCapital(str[a]));
|
2011-01-26 13:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void fil_tosmall(Info & i)
|
|
|
|
{
|
|
|
|
const std::wstring & str = i.in.Str();
|
|
|
|
|
|
|
|
for(size_t a=0 ; a<str.size() ; ++a)
|
2011-08-30 00:23:54 +02:00
|
|
|
i.out << R(locale.ToSmall(str[a]));
|
2011-01-26 13:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-27 15:35:25 +01:00
|
|
|
// 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;
|
|
|
|
|
2011-08-30 00:23:54 +02:00
|
|
|
i.out << R(locale.ToCapital(str[a]));
|
2011-01-27 15:35:25 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i.out << R(str[a]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( str[a] == '.' )
|
|
|
|
was_dot = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-26 13:45:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|