mirror of
https://github.com/znc/znc.git
synced 2026-05-02 11:32:29 +02:00
Add support for character encodings
Previous commit added support of it to Csocket. When encoding is specified, core will convert incoming messages to UTF-8, and outgoing messages from UTF-8. When no encoding is specified, it will do nothing to bytes, like before. This is to be changed somewhere in future, to have UTF-8 on wire by default too. When encoding's name starts with *, incoming messages will be treated as UTF-8, if it is already correct UTF-8. Otherwise, it's converted. Fix #151 Fix #366
This commit is contained in:
@@ -56,6 +56,7 @@ CIRCNetwork::CIRCNetwork(CUser *pUser, const CString& sName) {
|
||||
|
||||
m_sChanPrefixes = "";
|
||||
m_bIRCAway = false;
|
||||
m_sEncoding = "";
|
||||
|
||||
m_fFloodRate = 1;
|
||||
m_uFloodBurst = 4;
|
||||
@@ -78,6 +79,7 @@ CIRCNetwork::CIRCNetwork(CUser *pUser, const CIRCNetwork &Network) {
|
||||
|
||||
m_sChanPrefixes = "";
|
||||
m_bIRCAway = false;
|
||||
m_sEncoding = "";
|
||||
|
||||
m_RawBuffer.SetLineCount(100, true); // This should be more than enough raws, especially since we are buffering the MOTD separately
|
||||
m_MotdBuffer.SetLineCount(200, true); // This should be more than enough motd lines
|
||||
@@ -99,6 +101,7 @@ void CIRCNetwork::Clone(const CIRCNetwork& Network, bool bCloneName) {
|
||||
SetIdent(Network.GetIdent());
|
||||
SetRealName(Network.GetRealName());
|
||||
SetBindHost(Network.GetBindHost());
|
||||
SetEncoding(Network.GetEncoding());
|
||||
|
||||
// Servers
|
||||
const vector<CServer*>& vServers = Network.GetServers();
|
||||
@@ -259,6 +262,7 @@ bool CIRCNetwork::ParseConfig(CConfig *pConfig, CString& sError, bool bUpgrade)
|
||||
{ "ident", &CIRCNetwork::SetIdent },
|
||||
{ "realname", &CIRCNetwork::SetRealName },
|
||||
{ "bindhost", &CIRCNetwork::SetBindHost },
|
||||
{ "encoding", &CIRCNetwork::SetEncoding },
|
||||
};
|
||||
size_t numStringOptions = sizeof(StringOptions) / sizeof(StringOptions[0]);
|
||||
TOption<bool> BoolOptions[] = {
|
||||
@@ -405,6 +409,7 @@ CConfig CIRCNetwork::ToConfig() {
|
||||
config.AddKeyValuePair("IRCConnectEnabled", CString(GetIRCConnectEnabled()));
|
||||
config.AddKeyValuePair("FloodRate", CString(GetFloodRate()));
|
||||
config.AddKeyValuePair("FloodBurst", CString(GetFloodBurst()));
|
||||
config.AddKeyValuePair("Encoding", m_sEncoding);
|
||||
|
||||
// Modules
|
||||
CModules& Mods = GetModules();
|
||||
@@ -1102,6 +1107,10 @@ const CString& CIRCNetwork::GetBindHost() const {
|
||||
return m_sBindHost;
|
||||
}
|
||||
|
||||
const CString& CIRCNetwork::GetEncoding() const {
|
||||
return m_sEncoding;
|
||||
}
|
||||
|
||||
void CIRCNetwork::SetNick(const CString& s) {
|
||||
if (m_pUser->GetNick().Equals(s)) {
|
||||
m_sNick = "";
|
||||
@@ -1142,6 +1151,10 @@ void CIRCNetwork::SetBindHost(const CString& s) {
|
||||
}
|
||||
}
|
||||
|
||||
void CIRCNetwork::SetEncoding(const CString& s) {
|
||||
m_sEncoding = s;
|
||||
}
|
||||
|
||||
CString CIRCNetwork::ExpandString(const CString& sStr) const {
|
||||
CString sRet;
|
||||
return ExpandString(sStr, sRet);
|
||||
|
||||
Reference in New Issue
Block a user