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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:49:45+00:00 2026-05-15T02:49:45+00:00

i have a very simple question I can’t seem to get my head around.

  • 0

i have a very simple question I can’t seem to get my head around.

I have a properly encoded UTF8-String I parse into a JObject with Json.NET, fiddle around with some values and write it to the commandline, keeping the encoded characters intact.

Everything works great except for the keeping the encoded characters intact part.

Code:

var json = "{roster: [[\"Tulg\u00f4r\", 990, 1055]]}";
var j = JObject.Parse(json);
for (int i = 0; i < j["roster"].Count(); i++)
{
    j["roster"][i][1] = ((int)j["roster"][i][1]) * 3;
    j["roster"][i][2] = ((int)j["roster"][i][2]) * 3;
}
Console.WriteLine(JsonConvert.SerializeObject(j, Formatting.None));

Actual Output:

{"roster":[["Tulgôr",2970,3165]]}

Desired Output:

{"roster":[["Tulg\u00f4r",2970,3165]]}

It seems like my phrasing in Google is inappropriate since nothing useful came up. I’m sure it’s something uber-easy and i will feel pretty stupid afterwards. 🙂

  • 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-15T02:49:45+00:00Added an answer on May 15, 2026 at 2:49 am

    Take the output from JsonConvert.SerializeObject and run it through a helper method that converts all non-ASCII characters to their escaped (“\uHHHH”) equivalent. A sample implementation is given below.

    // Replaces non-ASCII with escape sequences;
    // i.e., converts "Tulgôr" to "Tulg\u00f4r".
    private static string EscapeUnicode(string input)
    {
        StringBuilder sb = new StringBuilder(input.Length);
        foreach (char ch in input)
        {
            if (ch <= 0x7f)
                sb.Append(ch);
            else
                sb.AppendFormat(CultureInfo.InvariantCulture, "\\u{0:x4}", (int) ch);
        }
        return sb.ToString();
    }
    

    You would call it as follows:

    Console.WriteLine(EscapeUnicode(JsonConvert.SerializeObject(j, Formatting.None)));
    

    (Note that I don’t handle non-BMP characters specially, because I don’t know if your third-party application wants “\U00010000” or “\uD800\uDC00” (or something else!) when representing U+10000.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple question for which I can't seem to find an
I have a very simple question, How can I get the POST values from
I have a very simple question, but can't seem to find a strait answer
I have a very simple question, but I don't seem to get it right.
very simple question (but I can't find the answer on the Web...): I have
very simple question: I have admin site in my web project. So, how can
This seems to me like a very simple question, but I can't seem to
I have a very simple question (I guess!) How can clone method be protected
This is no doubt a very simple question, but unfortunately I have looked around
I am hoping someone can help me. I have a very simple question, but

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.