mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Read all files as UTF-8 (#1035)
Fix encoding issues with some languages such as Chinese by forcing UTF-8 everywhere. Configuration files written in ANSI/Latin-1 and other encodings will need conversion.
This commit is contained in:
parent
cf9bc4c3d5
commit
20fb2323a4
9 changed files with 12 additions and 10 deletions
|
|
@ -399,7 +399,7 @@ namespace MinecraftClient
|
|||
{
|
||||
string[] lines = null;
|
||||
ChatBots.Script.LookForScript(ref script);
|
||||
try { lines = File.ReadAllLines(script); }
|
||||
try { lines = File.ReadAllLines(script, Encoding.UTF8); }
|
||||
catch (Exception e) { throw new CSharpException(CSErrorType.FileReadError, e); }
|
||||
return CSharpRunner.Run(this, tickHandler, lines, args, localVars);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -791,7 +791,7 @@ namespace MinecraftClient
|
|||
{
|
||||
//Read all lines from file, remove lines with no text, convert to lowercase,
|
||||
//remove duplicate entries, convert to a string array, and return the result.
|
||||
return File.ReadAllLines(file)
|
||||
return File.ReadAllLines(file, Encoding.UTF8)
|
||||
.Where(line => !String.IsNullOrWhiteSpace(line))
|
||||
.Select(line => line.ToLower())
|
||||
.Distinct().ToArray();
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace MinecraftClient.ChatBots
|
|||
if (Settings.DebugMessages)
|
||||
LogToConsole("Loading messages from file: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile));
|
||||
|
||||
dictionary = System.IO.File.ReadAllLines(Settings.AutoRelog_KickMessagesFile);
|
||||
dictionary = System.IO.File.ReadAllLines(Settings.AutoRelog_KickMessagesFile, Encoding.UTF8);
|
||||
|
||||
for (int i = 0; i < dictionary.Length; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace MinecraftClient.ChatBots
|
||||
|
|
@ -143,7 +144,7 @@ namespace MinecraftClient.ChatBots
|
|||
if (Settings.DebugMessages)
|
||||
LogToConsole("Loading matches from file: " + System.IO.Path.GetFullPath(matchesFile));
|
||||
|
||||
foreach (string lineRAW in File.ReadAllLines(matchesFile))
|
||||
foreach (string lineRAW in File.ReadAllLines(matchesFile, Encoding.UTF8))
|
||||
{
|
||||
string line = lineRAW.Split('#')[0].Trim();
|
||||
if (line.Length > 0)
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ namespace MinecraftClient.ChatBots
|
|||
{
|
||||
if (System.IO.File.Exists(English ? Settings.Hangman_FileWords_EN : Settings.Hangman_FileWords_FR))
|
||||
{
|
||||
string[] dico = System.IO.File.ReadAllLines(English ? Settings.Hangman_FileWords_EN : Settings.Hangman_FileWords_FR);
|
||||
string[] dico = System.IO.File.ReadAllLines(English ? Settings.Hangman_FileWords_EN : Settings.Hangman_FileWords_FR, Encoding.UTF8);
|
||||
return dico[new Random().Next(dico.Length)];
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ namespace MinecraftClient.ChatBots
|
|||
//Load the given file from the startup parameters
|
||||
if (LookForScript(ref file))
|
||||
{
|
||||
lines = System.IO.File.ReadAllLines(file);
|
||||
lines = System.IO.File.ReadAllLines(file, Encoding.UTF8);
|
||||
csharp = file.EndsWith(".cs");
|
||||
thread = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace MinecraftClient.ChatBots
|
|||
if (Settings.DebugMessages)
|
||||
LogToConsole("Loading tasks from '" + System.IO.Path.GetFullPath(tasksfile) + "'");
|
||||
TaskDesc current_task = null;
|
||||
String[] lines = System.IO.File.ReadAllLines(tasksfile);
|
||||
String[] lines = System.IO.File.ReadAllLines(tasksfile, Encoding.UTF8);
|
||||
foreach (string lineRAW in lines)
|
||||
{
|
||||
string line = lineRAW.Split('#')[0].Trim();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Mapping.BlockPalettes
|
||||
{
|
||||
|
|
@ -11,7 +12,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
|
|||
public static class BlockPaletteGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Generate mapping from Minecraft blocks.jsom
|
||||
/// Generate mapping from Minecraft blocks.json
|
||||
/// </summary>
|
||||
/// <param name="blocksJsonFile">path to blocks.json</param>
|
||||
/// <param name="outputClass">output path for blocks.cs</param>
|
||||
|
|
@ -23,7 +24,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
|
|||
HashSet<int> knownStates = new HashSet<int>();
|
||||
Dictionary<string, HashSet<int>> blocks = new Dictionary<string, HashSet<int>>();
|
||||
|
||||
Json.JSONData palette = Json.ParseJson(File.ReadAllText(blocksJsonFile));
|
||||
Json.JSONData palette = Json.ParseJson(File.ReadAllText(blocksJsonFile, Encoding.UTF8));
|
||||
foreach (KeyValuePair<string, Json.JSONData> item in palette.Properties)
|
||||
{
|
||||
//minecraft:item_name => ItemName
|
||||
|
|
|
|||
|
|
@ -1633,7 +1633,7 @@ namespace MinecraftClient
|
|||
public void OnExplosion(Location location, float strength, int affectedBlocks)
|
||||
{
|
||||
foreach (ChatBot bot in bots.ToArray())
|
||||
bot.OnExplosion(explode, strength, ExplosionRecordCount);
|
||||
bot.OnExplosion(location, strength, affectedBlocks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue