diff --git a/example-mods/chat-commands/chat-commands.cpp b/example-mods/chat-commands/chat-commands.cpp index 4803c2766b..30350521be 100644 --- a/example-mods/chat-commands/chat-commands.cpp +++ b/example-mods/chat-commands/chat-commands.cpp @@ -17,7 +17,9 @@ HOOK(chat_handle_packet_send, void, (const Minecraft *minecraft, ChatPacket *pac if (out.length() > 0 && out[out.length() - 1] == '\n') { out[out.length() - 1] = '\0'; } - gui->addMessage(out); + char *cp437_out = to_cp437(out.c_str()); + gui->addMessage(cp437_out); + free(cp437_out); } else { // Call Original Method real_chat_handle_packet_send()(minecraft, packet); diff --git a/mods/src/chat/chat.cpp b/mods/src/chat/chat.cpp index 408fe86b34..9053fc336c 100644 --- a/mods/src/chat/chat.cpp +++ b/mods/src/chat/chat.cpp @@ -10,7 +10,7 @@ #include "chat-internal.h" #include -// Send API Command +// Send UTF-8 API Command std::string chat_send_api_command(const Minecraft *minecraft, const std::string &str) { ConnectedClient client; client.sock = -1; @@ -26,7 +26,9 @@ std::string chat_send_api_command(const Minecraft *minecraft, const std::string // Send API Chat Command static void send_api_chat_command(const Minecraft *minecraft, const char *str) { - const std::string command = std::string("chat.post(") + str + ")\n"; + char *utf_str = from_cp437(str); + const std::string command = std::string("chat.post(") + utf_str + ")\n"; + free(utf_str); chat_send_api_command(minecraft, command); } @@ -45,6 +47,11 @@ void chat_send_message_to_clients(ServerSideNetworkHandler *server_side_network_ } // Handle Chat packet Send void chat_handle_packet_send(const Minecraft *minecraft, ChatPacket *packet) { + // Convert To CP-437 + char *cp437_str = to_cp437(packet->message.c_str()); + packet->message = cp437_str; + free(cp437_str); + // Send RakNetInstance *rak_net_instance = minecraft->rak_net_instance; if (rak_net_instance->isServer()) { // Hosting Multiplayer