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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:21:14+00:00 2026-06-11T09:21:14+00:00

What i am doing for changing html codes to JavaScript escapes is : string

  • 0

What i am doing for changing html codes to JavaScript escapes is :

string input = "श्रीगंग..."

var output = Regex.Replace(input, @"&#([0-9]*);", 
               x => String.Format("\\u{0:X4}", int.Parse(x.Groups[1].Value)));
or alternately;

var output = String.Join("", WebUtility.HtmlDecode(input)
                   .Select(x => "\\u" + ((int)x).ToString("X4")));

But now i have a problem that when i am sending this data through wcf service in json format. and i am getting values accordingly.
but only the output variable is going wrong which is in this format:

\\u0026\\u0023\\u0032\\u0033\\u0033\\u0037\\u003B\\u0026\\u0023\\u0032\\u0033\\u0037\\u0035\\u003B\\u0026\\u0023\\u0032\\u0033\\u0033\\u0038\\u003B\\u0026\\u0023\\u0032\\u0033\\u0036\\u0034\\u003B\\u0020\\u0026\\u0023\\u0032\\u0033\\u0032\\u0035\\u003B\\u0026\\u0023\\u0032\\u0033\\u0035

i don’t want ‘\\u0026’ but want only ‘\u0026’ in response.
i have tried everything like:

output.Replace("\\","'\'");
output.Replace("\\",@"\");

but didn.t work here.

Here is my WCF Service method:

 [OperationContract(Name = "GetByCity")]
        [WebInvoke(Method = "GET", UriTemplate = "/GetByCity/DeviceType={DeviceType}&CityId={id}&Limit={limit}", BodyStyle = WebMessageBodyStyle.WrappedRequest,
                    RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        NewsList GetByCity(string DeviceType, string id, string limit);

Now i don’t know where to define utf-8 format.

  • 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-06-11T09:21:15+00:00Added an answer on June 11, 2026 at 9:21 am

    The Unicode escpace sequence \u.... is used in C# source code and it’s used in JSON formatted data but it’s not used in C# string. C# strings fully support Unicode and have a direct representation for all Unicode characters.

    If required in the transmitted JSON data, the WCF service will create the escape sequence automatically. But if the strings already contain these escape sequences, then the WCF service will add more escaping so the unnecessary escape sequences will be retained after the JSON data has been parsed.

    So in order to fix your problem, you will need to replace the HTML entites (&#....;) with the real Unicode character, i.e. श needs to be replaced with the character having the Unicode code point 2358:

    var output = Regex.Replace(input, @"&#([0-9]*);", 
               x => new String((char) int.Parse(x.Groups[1].Value), 1) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing research on HTML canvas libraries and I came across this
I found a great plug-in for doing Auto-Complete with Javascript called AutoSuggest thanks to
I am doing one R&D and trying to find a answer of one problem.
I just got finished changing my entirely static HTML website into a PHP one
Doing the getting started of Sinatra. I get this error: ./sinatra.rb:5: undefined method `get'
Doing an ajax get request works as expected using the following code: $.ajax({ type:
Doing my first SL4 MVVM RIA based application and i ran into the following
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
Doing my first tryouts with foreign keys in a mySQL database and are trying
Doing some jquery animation. I have certain divs set up with an attribute of

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.