6

Is it possible? I want to check if a string is utf-8 encoded.

UPDATE: So, the problem is: I have a php webservice. This webservice has a method that receives a string. I'm trying to pass a VB.NET JSON string to this webservice. json_decode always returns an error, saying that the string is not utf-8. If I pass the string and convert it using PHP utf8_encode, the accents get wrong! How could I solve that?

7
  • How does your string look like? byte[]? Commented May 17, 2011 at 19:27
  • I've made this, but i don't know if it's alright: stackoverflow.com/questions/6035380/… . Thank you. Commented May 17, 2011 at 19:29
  • The only way I think will work without any third party tools is to just iterate over the byte array and test if it matches a known encoding. A great article with this is posted @ mobzystems.com/code/detecting-text-encoding.aspx Commented May 17, 2011 at 19:34
  • 2
    A System.String is never UTF-8. It's UTF-16. Only the byte representation of a string can be UTF-8. Commented May 17, 2011 at 19:50
  • 1
    Possible duplicate of Determine a string's encoding in C# Commented Oct 24, 2016 at 8:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.