Added SQL_SetCharset native to (re)set character set (bug 5999, r=ds).
This commit is contained in:
@ -138,6 +138,13 @@ namespace SourceMod
|
||||
* on internal failure.
|
||||
*/
|
||||
virtual int QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newsize) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the character set of the current connection
|
||||
*
|
||||
* @param characterset The characterset to switch to. e.g. "utf8".
|
||||
*/
|
||||
virtual bool SetCharacterSet(const char *characterset) =0;
|
||||
};
|
||||
|
||||
struct DatabaseInfo
|
||||
@ -149,6 +156,7 @@ namespace SourceMod
|
||||
const char *pass;
|
||||
unsigned int port;
|
||||
unsigned int max_timeout;
|
||||
const char *charset;
|
||||
};
|
||||
|
||||
class ISQLDriver
|
||||
|
@ -83,4 +83,7 @@ int MysqlDatabase::QuoteString(const char *str, char buffer[], size_t maxlen, si
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool MysqlDatabase::SetCharacterSet(const char *characterset)
|
||||
{
|
||||
return mysql_set_character_set(m_pMysql, characterset) == 0 ? true : false;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ namespace SourceMod
|
||||
IQuery *PrepareQueryFmt(const char *fmt, va_list ap);
|
||||
IQuery *PrepareQuery(const char *query);
|
||||
int QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newsize);
|
||||
bool SetCharacterSet(const char *characterset);
|
||||
private:
|
||||
void Disconnect();
|
||||
private:
|
||||
|
@ -72,6 +72,11 @@ IDatabase *MysqlDriver::_Connect(DatabaseInfo *info, int *errcode, char *error,
|
||||
|
||||
MysqlDatabase *pMysql = new MysqlDatabase(mysql, this);
|
||||
|
||||
if (info->charset && *info->charset)
|
||||
{
|
||||
pMysql->SetCharacterSet(info->charset);
|
||||
}
|
||||
|
||||
return static_cast<IDatabase *>(pMysql);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user