I need to stream an image to a .NET backend service using Windows 1252 encoding. So I believe I need to create a NSURLRequest
with its HTTPBodyStream
set to a NSInputStream
which is created with image data. And I need the encoding to be set to Windows 1252 or NSWindowsCP1252StringEncoding
.
I really have two questions:
- How do I tell
NSInputStream
to useNSWindowsCP1252StringEncoding
for its passed in data or file. - How would I convert a UIImage to ``NSWindowsCP1252StringEncoding` data? I only know of the base64 methods.
Edit:
This is the example .NET code that mimics a working client.
wr.Method = "POST";
wr.ContentType = "application/octet-stream";
wr.UseDefaultCredentials = true;
string ImagePath = @"C:\Users\smith\Desktop\Cat-and-dog.jpg";
byte[] ibuffer = File.ReadAllBytes(ImagePath);
wr.ContentLength = ibuffer.Length;
Stream pData = wr.GetRequestStream();
pData.Write(ibuffer, 0, ibuffer.Length);
pData.Close();
HttpWebResponse wres = wr.GetResponse() as HttpWebResponse;
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader strRdr = new StreamReader(wres.GetResponseStream(), enc);
string resp = strRdr.ReadToEnd();