* Changed XmlRpc to specify utf-8

afrisby
lbsa71 2007-07-05 18:31:59 +00:00
parent f7a938a21d
commit 8df2119bc7
4 changed files with 26 additions and 13 deletions

View File

@ -31,6 +31,7 @@ namespace Nwc.XmlRpc
using System.IO;
using System.Net.Sockets;
using System.Collections;
using System.Text;
///<summary>Very basic HTTP request handler.</summary>
///<remarks>This class is designed to accept a TcpClient and treat it as an HTTP request.
@ -55,8 +56,10 @@ namespace Nwc.XmlRpc
public SimpleHttpRequest(TcpClient client)
{
_client = client;
_output = new StreamWriter(client.GetStream());
_input = new StreamReader(client.GetStream());
_output = new StreamWriter(client.GetStream(), Encoding.UTF8 );
_input = new StreamReader(client.GetStream(), Encoding.UTF8 );
GetRequestMethod();
GetRequestHeaders();
}

View File

@ -56,7 +56,7 @@ namespace Nwc.XmlRpc
public class XmlRpcRequest
{
private String _methodName = null;
private Encoding _encoding = new ASCIIEncoding();
private Encoding _encoding = new UTF8Encoding();
private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();

View File

@ -30,6 +30,7 @@ namespace Nwc.XmlRpc
using System;
using System.Xml;
using System.Net.Sockets;
using System.Text;
/// <summary>The class is a container of the context of an XML-RPC dialog on the server side.</summary>
/// <remarks>Instances of this class maintain the context for an individual XML-RPC server
@ -100,6 +101,7 @@ namespace Nwc.XmlRpc
XmlRpcServer.HttpHeader(httpReq.Protocol, "text/xml", 0, " 200 OK", httpReq.Output);
httpReq.Output.Flush();
XmlTextWriter xml = new XmlTextWriter(httpReq.Output);
_serializer.Serialize(xml, xmlRpcResp);
xml.Flush();

View File

@ -31,6 +31,7 @@ namespace Nwc.XmlRpc
using System.Collections;
using System.IO;
using System.Xml;
using System.Text;
/// <summary>Base class of classes serializing data to XML-RPC's XML format.</summary>
/// <remarks>This class handles the basic type conversions like Integer to &lt;i4&gt;. </remarks>
@ -53,16 +54,23 @@ namespace Nwc.XmlRpc
/// <seealso cref="XmlRpcRequest"/>
public String Serialize(Object obj)
{
StringWriter strBuf = new StringWriter();
XmlTextWriter xml = new XmlTextWriter(strBuf);
using (MemoryStream memStream = new MemoryStream(4096))
{
XmlTextWriter xml = new XmlTextWriter(memStream, Encoding.UTF8);
xml.Formatting = Formatting.Indented;
xml.Indentation = 4;
Serialize(xml, obj);
xml.Flush();
String returns = strBuf.ToString();
byte[] resultBytes = memStream.ToArray();
UTF8Encoding encoder = new UTF8Encoding();
String returns = encoder.GetString( resultBytes, 0, resultBytes.Length );
xml.Close();
return returns;
}
}
/// <remarks>Serialize the object to the output stream.</remarks>
/// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>