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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:23:22+00:00 2026-06-05T23:23:22+00:00

I wanted code to convert all the characters in strings to uppercase or lowercase

  • 0

I wanted code to convert all the characters in strings to uppercase or lowercase in Java.

I found a method that goes something like this:

public static String changelowertoupper()
{
         String str = "CyBeRdRaGoN";
         str=str.toLowerCase(Locale.ENGLISH);
         return str;
}

Now I’ve read that using certain Locales, like Turkish, “returns i (without dot) instead of i (with dot).”

Is it safe to use Locales like UK, US, ENGLISH, etc.? Are there any big differences between them when applied to strings?

Which is the most preferred Locale for Strings?

  • 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-05T23:23:24+00:00Added an answer on June 5, 2026 at 11:23 pm

    I think you should use locale ,

    For instance, "TITLE".toLowerCase() in a Turkish locale returns
    "tıtle", where ‘ı’ is the LATIN SMALL LETTER DOTLESS I character. To
    obtain correct results for locale insensitive strings, use
    toLowerCase(Locale.ENGLISH).

    I refer to these links as solution to your problem
    and it has point to keep in mind in you situation "Turkish"

    **FROM THE LINKS**
    

    toLowerCase() respects internationalization (i18n). It performs the
    case conversion with respect to your Locale. When you call
    toLowerCase(), internally toLowerCase(Locale.getDefault()) is getting
    called. It is locale sensitive and you should not write a logic around
    it interpreting locale independently.

    import java.util.Locale;
     
    public class ToLocaleTest {
        public static void main(String[] args) throws Exception {
            Locale.setDefault(new Locale("lt")); //setting Lithuanian as locale
            String str = "\u00cc";
        System.out.println("Before case conversion is "+str+
    " and length is "+str.length());// Ì
            String lowerCaseStr = str.toLowerCase();
        System.out.println("Lower case is "+lowerCaseStr+
    " and length is "+lowerCaseStr.length());// iı`
        }
    }
    

    In the above program, look at the string length before and after
    conversion. It will be 1 and 3. Yes the length of the string before
    and after case conversion is different. Your logic will go for a toss
    when you depend on string length on this scenario. When your program
    gets executed in a different environment, it may fail. This will be a
    nice catch in code review.

    To make it safer, you may use another method
    toLowerCase(Locale.English) and override the locale to English always.
    But then you are not internationalized.

    So the crux is, toLowerCase() is locale specific.

    reference 1
    reference 2
    reference 3

    Dotless-i, is a lowercase ‘i’ without dot. The uppercase of this character is the usual "I". There is another character, "I with dot". The lowercase of this character is the usual lowercase "i".

    Have you noticed the problem? This unsymetrical conversion causes a serious problem in programming. We face this problem mostly in Java applications because of (IMHO) poor implementation of toLowerCase and toUpperCase functions.

    In Java, String.toLowerCase() method converts characters to lowercase according to the default locale. This causes problems if your application works in Turkish locale and especially if you are using this function for a file name or a url that must obey a certain character set.

    I have blogged about two serious examples before: The compile errors with Script libraries with "i" in their names and XSP Manager’s fault if an XPage is in a database with "I" in its name.

    There is a long history, as I said. For instance in some R7 version, router was unable to send a message to a recipient if his/her name starts with "I". Message reporting agents was not running in Turkish locale until R8. Anyone with Turkish locale could not install Lotus Notes 8.5.1 (it’s real!). The list goes on…

    There is almost no beta tester from Turkey and customers don’t open PMR for these problems. So these problems are not going up to the first priority for development teams.

    Even Java team has added a special warning to the latest documentation:

    This method is locale sensitive, and may produce unexpected results if
    used for strings that are intended to be interpreted locale
    independently. Examples are programming language identifiers, protocol
    keys, and HTML tags. For instance, "TITLE".toLowerCase() in a Turkish
    locale returns "tıtle", where ‘ı’ is the LATIN SMALL LETTER DOTLESS I
    character. To obtain correct results for locale insensitive strings,
    use toLowerCase(Locale.ENGLISH).

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

Sidebar

Related Questions

I have some code (which works fine) that looks something like this: int integer
When I wanted to get Android source code, I knew that I have to
I have a VB application. Clients wanted to convert that to a .net application.
So if I wanted to produce a bit of code to convert an flv
I am refactoring some code that I did not write, and I found a
I'm trying to convert some code from C# to C so that it can
I wanted to get the mouse image using C++. I used the code that
Wanted to know if someone had a suggestion on code or maybe there's a
I wanted to know why the following code crashes. int main( ) { int
I wanted to quick test a small snippet of PHP code. So, After doing

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.