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 3989686
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:24:15+00:00 2026-05-20T06:24:15+00:00

I am getting character codes (' and &quote;) that are breaking my responses (showing

  • 0

I am getting character codes (' and &quote;) that are breaking my responses (showing 39; and uto;) when returning a string from an HttpWebRequest:

internal static void TranslateThis(Player player, string fromLang, string toLang, string text){
    try
    {
        string translated = null;
        HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create("http://translate.google.com/?langpair=" + fromLang + "|" + toLang + "&text=" + text.Replace(" ", "+") + "#");
        HttpWebResponse res = (HttpWebResponse)hwr.GetResponse();
        StreamReader sr = new StreamReader(res.GetResponseStream());
        string html = sr.ReadToEnd();
        int a = html.IndexOf("onmouseout=\"this.style.backgroundColor='#fff'\">") + 47;
        int b = html.IndexOf("</span>",html.IndexOf("onmouseout=\"this.style.backgroundColor='#fff'\">") + 47);
        translated = html.Substring(a, b - a);
        if (translated.Length < (10 * text.Length)){
            if (player == Player.Console)
            {
                player.ParseMessage(translated, true);
            }
            else
            {
                player.ParseMessage(translated, false);
            }
        } else {
            player.Message("Usage: /translate [lang] [message]");
        }
    }
    catch
    {
        player.Message("Usage: /translate [lang] [message]");
    }
}
  • 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-20T06:24:16+00:00Added an answer on May 20, 2026 at 6:24 am

    Discussions with another developer go me to try this before the last lot of comments. Here is what ended up working:

        internal static void TranslateThis(Player player, string fromLang, string toLang, string text){
            try
            {
                string translated = null;
                text = Regex.Replace(text, @"[^\w\.\'\s@-]", "");
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://translate.google.com/?langpair=" + fromLang + "|" + toLang + "&text=" + text.Replace(" ", "+") + "#");
    
                request.MaximumAutomaticRedirections = 4;
                request.MaximumResponseHeadersLength = 4;
    
                request.Credentials = CredentialCache.DefaultCredentials;
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    
                Stream receiveStream = response.GetResponseStream();
    
                StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF7);
                String html = readStream.ReadToEnd() + "";
                int a = html.IndexOf("onmouseout=\"this.style.backgroundColor='#fff'\">") + 47;
                int b = html.IndexOf("</span>",html.IndexOf("onmouseout=\"this.style.backgroundColor='#fff'\">") + 47);
                translated = html.Substring(a, b - a);
                response.Close();
                readStream.Close();
                if (translated.Length < (10 * text.Length))
                {
                    translated = translated.Replace("&#39", "'");
                    translated = Regex.Replace(translated, @"[^\w\.\'\s@-]", "");
                    if (player == Player.Console)
                    {
                        player.ParseMessage(translated, true);
                    }
                    else
                    {
                        player.ParseMessage(translated, false);
                    }
                }
                else
                {
                    player.Message("Usage: /translate [lang] [message]");
                }
            }
            catch(Exception ex)
            {
                player.Message("Error:" + ex.ToString());
    
            }
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing a string that follows a predictable pattern: 1 character an integer (one
I want to check the last character of the String for characters that are
I am getting this compiler (gcc 4.5) warning: Formatter.cpp:23: warning: unknown conversion type character
When I am encrypting 23 using MD5 encryption I am getting 37693cfc748049e45d87b8c7d8b9aacd this 32-character
I have an application that has to deal with getting special characters in its
Getting the subdomain from a URL sounds easy at first. http://www.domain.example Scan for the
When getting the nodeValue of a DOMNode object that has entities in the nodeValue
I was trying to download an xml file that has '&' symbols in it
I recently decided to switch to clang from gcc and I’m getting the following
I am trying to extract publisher information from a string. It comes in various

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.