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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:18:23+00:00 2026-06-13T15:18:23+00:00

I have a six digit unicode character, for example U+100000 which I wish to

  • 0

I have a six digit unicode character, for example U+100000 which I wish to make a comparison with a another char in my C# code.

My reading of the MSDN documentation is that this character cannot be represented by a char, and must instead be represented by a string.

a Unicode character in the range U+10000 to U+10FFFF is not permitted in a character literal and is represented using a Unicode surrogate pair in a string literal

I feel that I’m missing something obvious, but how can you get the follow comparison to work correctly:

public bool IsCharLessThan(char myChar, string upperBound)
{
    return myChar < upperBound; // will not compile as a char is not comparable to a string
}

Assert.IsTrue(AnExample('\u0066', "\u100000"));
Assert.IsFalse(AnExample("\u100000", "\u100000")); // again won't compile as this is a string and not a char

edit

k, I think I need two methods, one to accept chars and another to accept ‘big chars’ i.e. strings. So:

public bool IsCharLessThan(char myChar, string upperBound)
{
    return true; // every char is less than a BigChar
}

public bool IsCharLessThan(string myBigChar, string upperBound)
{
    return string.Compare(myBigChar, upperBound) < 0;
}

Assert.IsTrue(AnExample('\u0066', "\u100000));
Assert.IsFalse(AnExample("\u100022", "\u100000"));
  • 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-13T15:18:24+00:00Added an answer on June 13, 2026 at 3:18 pm

    To construct a string with the Unicode code point U+10FFFF using a string literal, you need to work out the surrogate pair involved.

    In this case, you need:

    string bigCharacter = "\uDBFF\uDFFF";
    

    Or you can use char.ConvertFromUtf32:

    string bigCharacter = char.ConvertFromUtf32(0x10FFFF);
    

    It’s not clear what you want your method to achieve, but if you need it to work with characters not in the BMP, you’ll need to make it accept int instead of char, or a string.

    As per the documentation for string, if you want to iterate over characters in a string as full Unicode values, use TextElementEnumerator or StringInfo.

    Note that you do need to do this explicitly. If you just use ordinal values, it will check UTF-16 code units, not the UTF-32 code points. For example:

    string text = "\uF000";
    string upperBound = "\uDBFF\uDFFF";
    Console.WriteLine(string.Compare(text, upperBound, StringComparison.Ordinal));
    

    This prints out a value greater than zero, suggesting that text is greater than upperBound here. Instead, you should use char.ConvertToUtf32:

    string text = "\uF000";
    string upperBound = "\uDBFF\uDFFF";
    int textUtf32 = char.ConvertToUtf32(text, 0);
    int upperBoundUtf32 = char.ConvertToUtf32(upperBound, 0);
    Console.WriteLine(textUtf32 < upperBoundUtf32); // True
    

    So that’s probably what you need to do in your method. You might want to use StringInfo.LengthInTextElements to check that the strings really are single UTF-32 code points first.

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

Sidebar

Related Questions

I have the following code which displays only 1 result. However, I have six
I have six tables, which unfortunately does not have any primary/foreign key-relations encoded. I've
I have a solution which contains six projects. Four of the projects are class
I have a list of six digit codes (some are 7). What I need
I have six arrays which are of float type. Any specific index in all
I have a situation where I have six possible situations which can relate to
I have six twitter user names which I would like to display on my
I have six wcf services that I'm hosting in a windows service. Everything works
I have six SQL queries that I script though R that each take a
I am trying to plot a graph using gnuplot. I have six text files.

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.