How to UTF8 Encode the C# responseModel Object for Web API call

UTF8Encoding utf8 = new UTF8Encoding();
string unicodeString="Quick brown fox";
byte[] encodedBytes = utf8.GetBytes(unicodeString);

This work for a string. How can I do succeed at best doing this for the C# responseModel object before returning from a Web API call?

Thanks!! These odd characters are messing up the presentation layer in an Ipad app.
Who is Participating?
Bob LearnedConnect With a Mentor Commented:
"would this convert the response to utf-8 or would is depend on the response being utf-8."
It would send the response as UTF-8.
ste5anSenior DeveloperCommented:
D'oh? It's hard to guess without any information. Please post a concise and complete example. You're talking about a web api call, but I don't see any in your sample. Also I wouldn't call responseModel a common term - at least I don't know it. So please rephrase your question and give us more information.
gswitzAuthor Commented:
Sorry for not asking a clear enough question.

The object looks like this and actually includes an Objects type...

    public class ResponseModel
        public bool Success { get; set; }
        public string ErrorMessage { get; set; }
        public int ErrorCode { get; set; }
        public ArrayList DataCollection { get; set; }
        public object Data { get; set; }
        public int TotalRows { get; set; }

I can go downstream to the objects that inherit from it that looks like this...

    public class Article : IBaseEntity
        public string Type { get; set; }
        public List<ArticleInformation> Information { get; set; }

The service model binding includes a specification for UTF8
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
But, would this convert the response to utf-8 or would is depend on the response being utf-8.

Should I create separate questions here? Not sure.

Thanks for responding.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.