Solved

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

Posted on 2015-01-20
3
212 Views
Last Modified: 2015-02-05
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.
0
Comment
Question by:gswitz
3 Comments
 
LVL 32

Expert Comment

by:ste5an
ID: 40561479
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.
0
 

Author Comment

by:gswitz
ID: 40561966
Sorry for not asking a clear enough question.

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

    public class ResponseModel
    {
        [DataMember]
        [DefaultValue(true)]
        public bool Success { get; set; }
        [DataMember]
        public string ErrorMessage { get; set; }
        [DataMember]
        [DefaultValue(0)]
        public int ErrorCode { get; set; }
        [DataMember]
        public ArrayList DataCollection { get; set; }
        [DataMember]
        public object Data { get; set; }
        [DataMember]
        public int TotalRows { get; set; }

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


    [Serializable]
    [DataContract]
    public class Article : IBaseEntity
    {
        [DataMember]
        public string Type { get; set; }
        [DataMember]
        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.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 40562795
"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.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now