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

  • Home
  • SEARCH
  • 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 6668047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:59:52+00:00 2026-05-26T02:59:52+00:00

I’m getting the html from other page with problems in codification. For example: I

  • 0

I’m getting the html from other page with problems in codification.
For example:
I getting:

aparelho nas sa??das

the original text is:

aparelho nas saídas

How I get the encoding and convert to original string?

My code:

var GetResponse = API_GET("..."); //this returns html of an http request. 
HtmlDocument doc = new HtmlDocument();  //the html-parsing 
doc.LoadHtml(GetResponse);
var body = doc.DocumentNode.SelectNodes("//div[@class='para']"); 
... 
var para = body[i].InnerHtml; //Here's the problem,it returns the output like: sa??das

How I do this?

Thanks in advance

  • 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-26T02:59:52+00:00Added an answer on May 26, 2026 at 2:59 am

    Use this – kind of does this. Checks for just utf-8. I think it’s hard to check for encoding.

    When in doubt, convert it into UTF-8 or else encoding = WTF!

    http://utf8checker.codeplex.com/releases/view/40052

    Here’s part of the source code. Look at the IsUtf8 Methods. Can be quite useful.

    using System;
    using System.IO;
    
    namespace Unicode
    {
        /// <summary>
        /// http://anubis.dkuug.dk/JTC1/SC2/WG2/docs/n1335
        /// 
        /// http://www.cl.cam.ac.uk/~mgk25/ucs/ISO-10646-UTF-8.html
        /// 
        /// http://www.unicode.org/versions/corrigendum1.html
        /// 
        /// http://www.ietf.org/rfc/rfc2279.txt
        /// 
        /// </summary>
        public class Utf8Checker : IUtf8Checker
        {
            public bool Check(string fileName)
            {
                using (BufferedStream fstream = new BufferedStream(File.OpenRead(fileName)))
                {
                    return this.IsUtf8(fstream);
                }
            }
    
            /// <summary>
            /// Check if stream is utf8 encoded.
            /// Notice: stream is read completely in memory!
            /// </summary>
            /// <param name="stream">Stream to read from.</param>
            /// <returns>True if the whole stream is utf8 encoded.</returns>
            public bool IsUtf8(Stream stream)
            {
                int count = 4 * 1024;
                byte[] buffer;
                int read;
                while (true)
                {
                    buffer = new byte[count];
                    stream.Seek(0, SeekOrigin.Begin);
                    read = stream.Read(buffer, 0, count);
                    if (read < count)
                    {
                        break;
                    }
                    buffer = null;
                    count *= 2;
                }
                return IsUtf8(buffer, read);
            }
    
            /// <summary>
            /// 
            /// </summary>
            /// <param name="buffer"></param>
            /// <param name="length"></param>
            /// <returns></returns>
            public static bool IsUtf8(byte[] buffer, int length)
            {
                int position = 0;
                int bytes = 0;
                while (position < length)
                {
                    if (!IsValid(buffer, position, length, ref bytes))
                    {
                        return false;
                    }
                    position += bytes;
                }
                return true;
            }
    
            /// <summary>
            /// 
            /// </summary>
            /// <param name="buffer"></param>
            /// <param name="position"></param>
            /// <param name="length"></param>
            /// <param name="bytes"></param>
            /// <returns></returns>
            public static bool IsValid(byte[] buffer, int position, int length, ref int bytes)
            {
                if (length > buffer.Length)
                {
                    throw new ArgumentException("Invalid length");
                }
    
                if (position > length - 1)
                {
                    bytes = 0;
                    return true;
                }
    
                byte ch = buffer[position];
    
                if (ch <= 0x7F)
                {
                    bytes = 1;
                    return true;
                }
    
                if (ch >= 0xc2 && ch <= 0xdf)
                {
                    if (position >= length - 2)
                    {
                        bytes = 0;
                        return false;
                    }
                    if (buffer[position + 1] < 0x80 || buffer[position + 1] > 0xbf)
                    {
                        bytes = 0;
                        return false;
                    }
                    bytes = 2;
                    return true;
                }
    
                if (ch == 0xe0)
                {
                    if (position >= length - 3)
                    {
                        bytes = 0;
                        return false;
                    }
    
                    if (buffer[position + 1] < 0xa0 || buffer[position + 1] > 0xbf ||
                        buffer[position + 2] < 0x80 || buffer[position + 2] > 0xbf)
                    {
                        bytes = 0;
                        return false;
                    }
                    bytes = 3;
                    return true;
                }
    
    
                if (ch >= 0xe1 && ch <= 0xef)
                {
                    if (position >= length - 3)
                    {
                        bytes = 0;
                        return false;
                    }
    
                    if (buffer[position + 1] < 0x80 || buffer[position + 1] > 0xbf ||
                        buffer[position + 2] < 0x80 || buffer[position + 2] > 0xbf)
                    {
                        bytes = 0;
                        return false;
                    }
    
                    bytes = 3;
                    return true;
                }
    
                if (ch == 0xf0)
                {
                    if (position >= length - 4)
                    {
                        bytes = 0;
                        return false;
                    }
    
                    if (buffer[position + 1] < 0x90 || buffer[position + 1] > 0xbf ||
                        buffer[position + 2] < 0x80 || buffer[position + 2] > 0xbf ||
                        buffer[position + 3] < 0x80 || buffer[position + 3] > 0xbf)
                    {
                        bytes = 0;
                        return false;
                    }
    
                    bytes = 4;
                    return true;
                }
    
                if (ch == 0xf4)
                {
                    if (position >= length - 4)
                    {
                        bytes = 0;
                        return false;
                    }
    
                    if (buffer[position + 1] < 0x80 || buffer[position + 1] > 0x8f ||
                        buffer[position + 2] < 0x80 || buffer[position + 2] > 0xbf ||
                        buffer[position + 3] < 0x80 || buffer[position + 3] > 0xbf)
                    {
                        bytes = 0;
                        return false;
                    }
    
                    bytes = 4;
                    return true;
                }
    
                if (ch >= 0xf1 && ch <= 0xf3)
                {
                    if (position >= length - 4)
                    {
                        bytes = 0;
                        return false;
                    }
    
                    if (buffer[position + 1] < 0x80 || buffer[position + 1] > 0xbf ||
                        buffer[position + 2] < 0x80 || buffer[position + 2] > 0xbf ||
                        buffer[position + 3] < 0x80 || buffer[position + 3] > 0xbf)
                    {
                        bytes = 0;
                        return false;
                    }
    
                    bytes = 4;
                    return true;
                }
    
                return false;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has

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.