added support for UTF-8

now the UTF-8 is a default charset


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@677 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-11-21 00:19:17 +00:00
parent f1f0fa34cb
commit 8e72a820dd
153 changed files with 4270 additions and 2784 deletions

View File

@@ -18,7 +18,106 @@ namespace TemplatesFunctions
{
void print_date_nice(Ezc::Info & i, const tm & rtm)
bool HtmlTryChar(TextStream<std::wstring> & out, wchar_t c)
{
if( c == '<' )
{
out << L"&lt;";
return true;
}
else
if( c == '>' )
{
out << L"&gt;";
return true;
}
else
if( c == '&' )
{
out << L"&amp;";
return true;
}
return false;
}
void HtmlEscape(TextStream<std::wstring> & out, const std::wstring & in)
{
std::wstring::const_iterator i;
for(i = in.begin() ; i != in.end() ; ++i)
{
if( !HtmlTryChar(out, *i) )
out << *i;
}
}
std::wstring HtmlEscape(const std::wstring & in)
{
TextStream<std::wstring> out;
HtmlEscape(out, in);
return out.Str();
}
void HtmlEscapeFormTxt(TextStream<std::wstring> & out, const std::wstring & in)
{
std::wstring::const_iterator i;
int was_enter = 0; // how many enteres there were before
if( in.empty() )
return;
out << L"<p>"; // !! pozbyc sie wstawianie tego html tutaj (wrzucic w jakis sposob do szablonow)
// skipping first new line characters
for(i = in.begin() ; i != in.end() && (*i==13 || *i==10) ; ++i);
for( ; i != in.end() ; ++i )
{
if( *i == 13 ) // skipping stupid characters (\r\n\ in dos mode)
continue;
if( *i == 10 )
{
++was_enter;
}
else
{
if( was_enter == 1 )
out << L"<br>\n";
else
if( was_enter > 1 )
out << L"</p>\n<p>";
was_enter = 0;
}
if( !HtmlTryChar(out, *i) )
out << *i;
}
out << L"</p>\n";
}
std::wstring HtmlEscapeFormTxt(const std::wstring & in)
{
TextStream<std::wstring> out;
HtmlEscapeFormTxt(out, in);
return out.Str();
}
void print_date_nice(Info & i, const tm & rtm)
{
time_t t = Time(rtm);
time_t now = std::time(0);
@@ -33,7 +132,7 @@ void print_date_nice(Ezc::Info & i, const tm & rtm)
}
void print_user_name(Ezc::Info & i, const User * puser, const std::string & guest_name)
void print_user_name(Info & i, const User * puser, const std::wstring & guest_name)
{
if( puser )
{
@@ -62,8 +161,9 @@ int ParseCKeditorFun()
if( !request->get_tab[last].empty() )
{
const char * str = request->get_tab[last].c_str() + 1; // the first char is '?'
ckeditor_getparser.Parse(str);
static std::string get;
AssignString(request->get_tab[last], get);
ckeditor_getparser.Parse(get.c_str() + 1); // the first char is '?'
}
}
@@ -76,7 +176,7 @@ return ckeditor_getparser.fun_num;
// those functions from here are used in the second thread too
void Read(Patterns & patterns, size_t pat, Locale & locale, LocaleFilter & locale_filter, const char * file, bool delete_white)
void Read(Patterns & patterns, size_t pat, Locale & locale, LocaleFilter & locale_filter, const wchar_t * file, bool delete_white)
{
size_t i;
size_t len = patterns.size();
@@ -85,6 +185,7 @@ void Read(Patterns & patterns, size_t pat, Locale & locale, LocaleFilter & local
{
if( pat < patterns[i].size() )
{
patterns[i][pat].UTF8(true); // !! powinno byc brane z konfiga
patterns[i][pat].DeleteWhiteTextItems(delete_white);
patterns[i][pat].Directory(config->templates_dir, config->templates_dir_default);
patterns[i][pat].ParseFile(file);