Skip to content

Commit

Permalink
当使用 utf8 / utf8mb4 作为数据库编码时不再给予警告 (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
CairoLee committed Aug 2, 2022
1 parent 8deaf3f commit f82af83
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 38 deletions.
8 changes: 4 additions & 4 deletions conf/msg_conf/translation_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1882,8 +1882,6 @@ Body:
Translation: ""
- Original: "Please use '%s' instead!\n"
Translation: ""
- Original: "Please use ANSI character set as database encoding instead of [{CL_WHITE}]'%s'[{CL_RESET}] for [{CL_WHITE}]'%s'[{CL_RESET}] connection. The ANSI character set like: latin1, gbk, big5.\n"
Translation: "建议使用 ANSI 编码作为数据库字符集, 而不是用 [{CL_WHITE}]'%s'[{CL_RESET}] 作为 [{CL_WHITE}]'%s'[{CL_RESET}] 连接所指向的数据库的字符集 (ANSI 编码是指: latin1, gbk, big5 等).\n"
- Original: "Press any key to continue reading other files, but it usually means a lot of errors.\n"
Translation: "按任意键继续加载其他文件, 但后续可能会出现更多错误 (建议先修正以下错误).\n"
- Original: "Prevented infinite warp loop for player (%d:%d). Please fix NPC: '%s', path: '%s'\n"
Expand Down Expand Up @@ -2026,8 +2024,6 @@ Body:
Translation: "正在发送当前服务器支持的地图列表给角色服务器...\n"
- Original: "Sending users of map-server %d offline.\n"
Translation: "正在给地图服务器 %d 的玩家发送下线请求.\n"
- Original: "Server and client is not support Non-ANSI character set very well.\n"
Translation: "仙境传说模拟器和客户端对非 ANSI 编码的字符集支持并不友好.\n"
- Original: "Server crashdump file will be saved to: [{CL_WHITE}]'%s/'[{CL_RESET}]\n"
Translation: "服务端程序崩溃时转储文件将保存到: [{CL_WHITE}]'%s/'[{CL_RESET}]\n"
- Original: "Server has crashed while trying to save characters. Character data can't be saved!\n"
Expand Down Expand Up @@ -5776,3 +5772,7 @@ Body:
Translation: ""
- Original: "wrong egg item inventory %d\n"
Translation: ""
- Original: "Please use ANSI character set as database encoding instead of [{CL_WHITE}]'%s'[{CL_RESET}] for [{CL_WHITE}]'%s'[{CL_RESET}] connection. The ANSI character set like: latin1, gbk, big5.\n"
Translation: "建议使用 ANSI 编码作为数据库字符集, 而不是用 [{CL_WHITE}]'%s'[{CL_RESET}] 作为 [{CL_WHITE}]'%s'[{CL_RESET}] 连接所指向的数据库的字符集 (ANSI 编码是指: latin1, gbk, big5 等).\n"
- Original: "Server and client is not support Non-ANSI character set very well.\n"
Translation: "仙境传说模拟器和客户端对非 ANSI 编码的字符集支持并不友好.\n"
8 changes: 4 additions & 4 deletions conf/msg_conf/translation_tw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1882,8 +1882,6 @@ Body:
Translation: ""
- Original: "Please use '%s' instead!\n"
Translation: ""
- Original: "Please use ANSI character set as database encoding instead of [{CL_WHITE}]'%s'[{CL_RESET}] for [{CL_WHITE}]'%s'[{CL_RESET}] connection. The ANSI character set like: latin1, gbk, big5.\n"
Translation: "建議使用 ANSI 編碼作為資料庫字符集, 而不是用 [{CL_WHITE}]'%s'[{CL_RESET}] 作為 [{CL_WHITE}]'%s'[{CL_RESET}] 連線所指向的資料庫的字符集 (ANSI 編碼是指: latin1, gbk, big5 等).\n"
- Original: "Press any key to continue reading other files, but it usually means a lot of errors.\n"
Translation: "按任意鍵繼續載入其他檔案, 但後續可能會出現更多錯誤 (建議先修正以下錯誤).\n"
- Original: "Prevented infinite warp loop for player (%d:%d). Please fix NPC: '%s', path: '%s'\n"
Expand Down Expand Up @@ -2026,8 +2024,6 @@ Body:
Translation: "正在傳送當前伺服器支援的地圖列表給角色伺服器...\n"
- Original: "Sending users of map-server %d offline.\n"
Translation: "正在給地圖伺服器 %d 的玩家傳送下線請求.\n"
- Original: "Server and client is not support Non-ANSI character set very well.\n"
Translation: "仙境傳說模擬器和客戶端對非 ANSI 編碼的字符集支援並不友好.\n"
- Original: "Server crashdump file will be saved to: [{CL_WHITE}]'%s/'[{CL_RESET}]\n"
Translation: "服務端程式崩潰時轉儲檔案將儲存到: [{CL_WHITE}]'%s/'[{CL_RESET}]\n"
- Original: "Server has crashed while trying to save characters. Character data can't be saved!\n"
Expand Down Expand Up @@ -5776,3 +5772,7 @@ Body:
Translation: ""
- Original: "wrong egg item inventory %d\n"
Translation: ""
- Original: "Please use ANSI character set as database encoding instead of [{CL_WHITE}]'%s'[{CL_RESET}] for [{CL_WHITE}]'%s'[{CL_RESET}] connection. The ANSI character set like: latin1, gbk, big5.\n"
Translation: "建議使用 ANSI 編碼作為資料庫字符集, 而不是用 [{CL_WHITE}]'%s'[{CL_RESET}] 作為 [{CL_WHITE}]'%s'[{CL_RESET}] 連線所指向的資料庫的字符集 (ANSI 編碼是指: latin1, gbk, big5 等).\n"
- Original: "Server and client is not support Non-ANSI character set very well.\n"
Translation: "仙境傳說模擬器和客戶端對非 ANSI 編碼的字符集支援並不友好.\n"
26 changes: 0 additions & 26 deletions src/common/sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,32 +254,6 @@ int Sql_SetEncoding(Sql* self, const char* encoding, const char* default_encodin
break;
}

// 如果使用的编码是 utf8 或 utf8mb4 中的任何一个, 则给予警告 (WEB 接口服务器除外)
if (SERVER_TYPE != ATHENA_SERVER_WEB) {
size_t i = 0;
const char* non_ansi[] = { "utf8", "utf8mb4" };
ARR_FIND(0, ARRAYLENGTH(non_ansi), i, stricmp(current_codepage, non_ansi[i]) == 0);
if (ARRAYLENGTH(non_ansi) > i) {
#ifndef BUILDBOT
if (connect_name != nullptr) {
ShowWarning("Server and client is not support Non-ANSI character set very well.\n");
ShowWarning("Please use ANSI character set as database encoding instead of " CL_WHITE "'%s'" CL_RESET " for " CL_WHITE "'%s'" CL_RESET " connection. The ANSI character set like: latin1, gbk, big5.\n", current_codepage, connect_name);
}
#endif // BUILDBOT

// 若目标数据库使用 utf8 或者 utf8mb4 编码,
// 为了兼容性考虑, 会根据操作系统语言来选择使用 gbk 或 big5 编码,
// 若不是简体中文也不是繁体中文, 则直接使用当前数据库的 `character_set_database` 编码
switch (PandasUtf8::systemLanguage) {
case PandasUtf8::PANDAS_LANGUAGE_CHS: encoding = "gbk"; break;
case PandasUtf8::PANDAS_LANGUAGE_CHT: encoding = "big5"; break;
default: encoding = current_codepage; break;
}

break;
}
}

// 将连接编码设置为与数据库的 server character set 完全一致
encoding = current_codepage;
} while (false);
Expand Down
4 changes: 0 additions & 4 deletions src/config/pandas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,6 @@
//
// - 能够输出目标数据库当前所使用的编码
// - 当在 inter_athena.conf 中指定了 codepage 时, 能提示最终使用的编码
// - 若目标数据库使用 utf8 或者 utf8mb4 编码则会给与提示
// - 若目标数据库使用 utf8 或者 utf8mb4 编码, 为了兼容性考虑会根据操作
// 系统语言来选择使用 gbk 或 big5 编码, 若不是简体中文也不是繁体中文则直接
// 使用当前数据库的 `character_set_database` 编码.
//
// --------------------------------------
// 改动三:用 mysql_set_character_set 来设置 MySQL 的编码字符集
Expand Down

0 comments on commit f82af83

Please sign in to comment.