?
Solved

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

Posted on 2015-01-20
3
Medium Priority
?
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 35

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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

801 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