From 7286bd60b07e809f33215256cc71b39c15437c65 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 21 Mar 2008 02:26:00 +0000 Subject: [PATCH] * Converted a large number of ASCII encodings to UTF8. * We should not be using ASCII anywhere except for legacy compatibility reasons. * A large number of UTF8 Encoders are being used in places where we should be using Util.StringToField instead. These have been tagged with // ENCODING FAULT * This should fix Mantis#799 - Japanese Profile Text does not work. --- .../Communications/Capabilities/LLSD.cs | 2 +- .../Configuration/HTTP/HTTPConfiguration.cs | 2 +- OpenSim/Region/ClientStack/ClientView.cs | 20 ++++++++++++------- OpenSim/Region/Environment/EstateManager.cs | 3 ++- .../Modules/ScriptsHttpRequests.cs | 2 +- .../Environment/Scenes/SceneObjectGroup.cs | 3 ++- .../Common/LSL_BuiltIn_Commands.cs | 1 - 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index 8e2a194605..b3e841c6dc 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -329,7 +329,7 @@ namespace OpenSim.Region.Capabilities reader.Read(); FromBase64Transform b64 = new FromBase64Transform(FromBase64TransformMode.IgnoreWhiteSpaces); - byte[] inp = Encoding.ASCII.GetBytes(reader.ReadString()); + byte[] inp = Encoding.UTF8.GetBytes(reader.ReadString()); ret = b64.TransformFinalBlock(inp, 0, inp.Length); break; } diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs index fa8d8fe78a..1fb4866ef6 100644 --- a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs +++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs @@ -74,7 +74,7 @@ namespace OpenSim.Framework.Configuration.HTTP count = resStream.Read(buf, 0, buf.Length); if (count != 0) { - tempString = Encoding.ASCII.GetString(buf, 0, count); + tempString = Encoding.UTF8.GetString(buf, 0, count); sb.Append(tempString); } } while (count > 0); diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index f1ecc8a356..0215994bad 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -84,7 +84,8 @@ namespace OpenSim.Region.ClientStack private int m_lastPacketsReceived = 0; private byte[] ZeroOutBuffer = new byte[4096]; - private readonly Encoding m_encoding = Encoding.ASCII; + // ENCODING FAULT + private readonly Encoding m_encoding = Encoding.UTF8; private readonly LLUUID m_agentId; private readonly uint m_circuitCode; private int m_moneyBalance; @@ -1165,7 +1166,8 @@ namespace OpenSim.Region.ClientStack // 6 to 7 items at a time, so let's stick with 6 int MAX_ITEMS_PER_PACKET = 6; - Encoding enc = Encoding.ASCII; + // ENCODING FAULT + Encoding enc = Encoding.UTF8; uint FULL_MASK_PERMISSIONS = 2147483647; if (fetchItems) @@ -1336,7 +1338,8 @@ namespace OpenSim.Region.ClientStack public void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item) { - Encoding enc = Encoding.ASCII; + // ENCODING FAULT + Encoding enc = Encoding.UTF8; uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All; FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply); // TODO: don't create new blocks if recycling an old packet @@ -1378,7 +1381,8 @@ namespace OpenSim.Region.ClientStack /// IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase) public void SendInventoryItemCreateUpdate(InventoryItemBase Item) { - Encoding enc = Encoding.ASCII; + // ENCODING FAULT + Encoding enc = Encoding.UTF8; uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All; UpdateCreateInventoryItemPacket InventoryReply = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.UpdateCreateInventoryItem); // TODO: don't create new blocks if recycling an old packet @@ -2213,7 +2217,8 @@ namespace OpenSim.Region.ClientStack { objdata.TextureEntry = textureEntry; } - Encoding enc = Encoding.ASCII; + // ENCODING FAULT + Encoding enc = Encoding.UTF8; LLVector3 pos = new LLVector3(objdata.ObjectData, 16); pos.X = 100f; objdata.ID = 8880000; @@ -2941,7 +2946,8 @@ namespace OpenSim.Region.ClientStack } else { - Encoding _enc = Encoding.ASCII; + // ENCODING FAULT + Encoding _enc = Encoding.UTF8; switch (Pack.Type) { @@ -3989,7 +3995,7 @@ namespace OpenSim.Region.ClientStack OutPacket(tpStart, ThrottleOutPacketType.Task); TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress); - tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark"); + tpProgress.Info.Message = (new UTF8Encoding()).GetBytes("sending_landmark"); tpProgress.Info.TeleportFlags = 8; tpProgress.AgentData.AgentID = tpReq.Info.AgentID; OutPacket(tpProgress, ThrottleOutPacketType.Task); diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs index 39efecdb7d..9c53f389c0 100644 --- a/OpenSim/Region/Environment/EstateManager.cs +++ b/OpenSim/Region/Environment/EstateManager.cs @@ -634,7 +634,8 @@ namespace OpenSim.Region.Environment public void sendRegionInfoPacket(IClientAPI remote_client) { - Encoding _enc = Encoding.ASCII; + // ENCODING FAULT + Encoding _enc = Encoding.UTF8; AgentCircuitData circuitData = remote_client.RequestClientInfo(); diff --git a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs index ebc856842d..10e3840705 100644 --- a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs @@ -328,7 +328,7 @@ namespace OpenSim.Region.Environment.Modules if (count != 0) { // translate from bytes to ASCII text - tempString = Encoding.ASCII.GetString(buf, 0, count); + tempString = Encoding.UTF8.GetString(buf, 0, count); // continue building the string sb.Append(tempString); diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 327956e1b1..b0ed04e5f3 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -45,7 +45,8 @@ namespace OpenSim.Region.Environment.Scenes public partial class SceneObjectGroup : EntityBase { - private Encoding enc = Encoding.ASCII; + // ENCODING FAULT + private Encoding enc = Encoding.UTF8; protected SceneObjectPart m_rootPart; diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index f9259551ae..a3f546d365 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -51,7 +51,6 @@ namespace OpenSim.Region.ScriptEngine.Common { // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - // private ASCIIEncoding enc = new ASCIIEncoding(); private ScriptEngineBase.ScriptEngine m_ScriptEngine; private SceneObjectPart m_host; private uint m_localID;