views:

616

answers:

1

Basically I want to pass a string which contains Spanish text that could be in one of several encodings (Latin-1, CP-1252, or UTF-8 to name a few). Once it gets to the XMLRPC I can detect the encoding, but I won't know it before then. C#, by default seems to be killing any characters outside of ASCII. I've gotten around the problem by base64-encoding the string but I'd really love to NOT do that.

I'm using CookComputing.XmlRpc... Here's a code snippet of my interface:

public interface ISpanishAnalyzer
{
    [XmlRpcMethod("analyzeSpanishString")]
    int analyzeSpanishString(string text);
}

Any help would be appreciated. Thanks!

+2  A: 

I don't think there is really a better way then base64 encoding. As long as you do not know the encoding, you have no other possibility as to handle it as a byte array. The only change I would suggest is to make this explicit by using a byte[] parameter instead of a string and letting the XmlRpc library to take care of the base64 encoding (assuming that it supports this).

csgero