Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1069153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:22:43+00:00 2026-05-16T20:22:43+00:00

Well, sorry about the confusing title but I’m having a slightly annoying problem with

  • 0

Well, sorry about the confusing title but I’m having a slightly annoying problem with character encoding in C#.NET

I have a bunch of classes generated from WSDL files, these classes have methods which take string parameters which are then submitted to a remote web service. This remote web service expects all text input to be UTF-8 encoded. Now, as far as I can tell there really isn’t a way to make a string in C#.NET UTF-8 encoded, it’s UTF-16 or nothing, if I want UTF-8 I have to make it a byte[], right?

So, my big question is, how am I supposed to put my raw UTF-8 byte[] data into a string so I can actually submit it to the web service? I mean, sure, I could probably fall back on C-style code, looping through the whole thing byte by byte but surely Microsoft must have thought about this when designing the language and API? (although since my Vista laptop thinks it’s perfectly alright to use UTF-16 internally, cp1252 for some stuff, UTF-8 for some other and cp850(!) for some other stuff I wouldn’t be too surprised if they didn’t).

So, am I stuck doing things the ugly way or is there some hidden System.Text.EncodeStuffTherightWay.EncodeStringAsUTF8(string) method deep in the bowels of .NET?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:22:44+00:00Added an answer on May 16, 2026 at 8:22 pm

    Strings never contain anything utf-* or anything else encoded; that isn’t their job. They are strings – groups of character/code-point data. The byte[] that you have is the encoded form.

    In almost any scenario I can think of, the transport etc should be doing this for you already. If isn’t then that sounds like a bug in either the wsdl or the web-service stack itself.

    Keep in mind that wsdl itself just has xs:string – if that isn’t sufficient (i.e. that in combination with the handshake isn’t enough), then it simply isn’t a web-service string.

    The alternative is to throw it around as a byte[], and encode manually via

    byte[] bytes=Encoding.UTF8.GetBytes(yourString);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sorry to have to bring up this as well. But it doesn't seem
Sorry for the non-technical title, but I think it summarizes my question well. If
Sorry for the unhelpful title, but hopefully I can explain this well enough. Lets
Sorry about the terrible title. I have a signed assembly 'Signed.dll' that is a
Sorry if title is not too clear but I think it's about right. NEhow,
Well lets try to explain am sorry about my english. I have some xml
Well, first of all sorry about this question it must be pretty straight forward
Sorry this is not a very well defined question, I am thinking about an
Well this probably isn't specific to rails, but in my rails app, I have
Sorry about the poorly articulated title, I couldn't think of a title that would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.