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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:27:41+00:00 2026-05-20T18:27:41+00:00

I am converting the following C# code to Java. Is there a Java equivalent

  • 0

I am converting the following C# code to Java. Is there a Java equivalent to the .NET concept of Invariant Culture?

string upper = myString.ToUpperInvariant();

Since the Invariant Culture is really just the US culture, I could just do something like this in Java, but I’m wondering if there is a better way:

String upper = myString.toUpperCase(Locale.US);
  • 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-20T18:27:41+00:00Added an answer on May 20, 2026 at 6:27 pm

    Update: Java 6 introduced Locale.ROOT which is described as:

    This is regarded as the base locale of all locales, and is used as the language/country neutral locale for the locale sensitive operations.

    This is probably better than using US, but I haven’t checked it against the code below.


    No, that’s basically the right way to go. While there are differences between the US culture and the invariant culture in terms of formatting, I don’t believe they affect casing rules.

    EDIT: Actually, a quick test program shows there are characters which are upper-cased differently in .NET in the US culture to in the invariant culture:

    using System;
    using System.Globalization;
    
    class Test
    {
        static void Main()
        {
            CultureInfo us = new CultureInfo("en-US");
            for (int i = 0; i < 65536; i++)
            {
                char c = (char) i;
                string s = c.ToString();
                if (s.ToUpperInvariant() != s.ToUpper(us))
                {
                    Console.WriteLine(i.ToString("x4"));
                }
            }
        }    
    }
    

    Output:

    00b5
    0131
    017f
    01c5
    01c8
    01cb
    01f2
    0345
    0390
    03b0
    03c2
    03d0
    03d1
    03d5
    03d6
    03f0
    03f1
    03f5
    1e9b
    1fbe
    

    I don’t have time to look at these right now, but it’s worth investigating. I don’t know if the same differences would apply in Java – you probably want to take a sample of them and work out what you want your code to do.

    EDIT: And just to be completist, it’s worth mentioning that that only checks for individual characters… whereas you’re really upper-casing whole strings, which can make a difference.

    Looking at the Java code for upper-casing, that appears to only have locale-specific behaviour for tr, az and lt countries. I know that tr is Turkey, but I don’t know about the others…

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

Sidebar

Related Questions

Newbie to C++ learning by converting a java program to c++. The following code
Let's consider the following code snippet in Java. There are some of possible approaches
I have the following java code: nameFinderModel = NameFinderME.train(en, organization, sampleStream, Collections.<String, Object>emptyMap()); And
I am manually converting Java to C# and have the following code: for (Iterator<SGroup>
I am converting Java into C# and have the following code (see discussion in
I'm converting a image to gray scale in Java with the following code: BufferedImage
I am converting code from c# to java. I have the following xml structure:
I am in the process of converting some code from C# to Java. I
I'm just beginning in scala and I'm converting some java code into scala and
The following Code System.out.println(Start); String s = ; //936 * 5 = 4680 characters

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.