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

@@ -7,13 +7,13 @@
*
*/
#include "dbbase.h"
#include "core/log.h"
#include "core/error.h"
#include <stdlib.h>
#include <limits.h>
#include <limits>
#include "dbbase.h"
#include "core/log.h"
#include "core/error.h"
#include "ezc.h"
DbBase::DbBase()
@@ -86,7 +86,7 @@ return r;
}
PGresult * DbBase::AssertQuery(const std::string & q)
PGresult * DbBase::AssertQuery(const std::wstring & q)
{
return AssertQuery(q.c_str());
}
@@ -117,7 +117,6 @@ int DbBase::AssertColumn(PGresult * r, const char * column_name)
if( c == -1 )
{
log << log1 << "Db: there is no column: " << column_name << logend;
throw Error(WINIX_ERR_DB_NO_COLUMN);
}
@@ -132,7 +131,6 @@ const char * DbBase::AssertValue(PGresult * r, int row, int col)
if( !res )
{
log << log1 << "Db: there is no such an item in the result, row:" << row << ", col:" << col << logend;
throw Error(WINIX_ERR_NO_ITEM);
}
@@ -140,6 +138,24 @@ return res;
}
const std::wstring & DbBase::AssertValueWide(PGresult * r, int row, int col)
{
const char * res = AssertValue(r, row, col);
static std::wstring temp_wide_value;
Ezc::UTF8ToWide(res, temp_wide_value);
return temp_wide_value;
}
void DbBase::AssertValueWide(PGresult * r, int row, int col, std::wstring & result)
{
const char * res = AssertValue(r, row, col);
Ezc::UTF8ToWide(res, result);
}
long DbBase::AssertValueLong(PGresult * r, int row, int col)
{
return strtol( AssertValue(r, row, col), 0, 10 );
@@ -300,9 +316,10 @@ return buffer;
void DbBase::CreateIdList(const std::vector<long> & id_tab, std::string & list, bool add_parentheses)
void DbBase::CreateIdList(const std::vector<long> & id_tab, std::wstring & list, bool add_parentheses)
{
char buffer[50];
wchar_t buffer[50];
size_t buffer_len = sizeof(buffer) / sizeof(wchar_t);
list.clear();
@@ -311,7 +328,7 @@ char buffer[50];
for(size_t i=0 ; i<id_tab.size() ; ++i)
{
sprintf(buffer, "%lu", (unsigned long)id_tab[i]);
swprintf(buffer, buffer_len, L"%lu", (unsigned long)id_tab[i]);
list += buffer;
if( i+1 < id_tab.size() )