Internationalization and localization tools

Locale-Sensitive Java Method


public String toLowerCase()

public String toLowerCase(Locale locale)

Internationalization (I18n) Method Overview

This method attempts to convert all of the characters in this String to lower case using the case transformation rules of the specified locale or the default locale. If no locale is passed as an argument, this is equivalent to calling toLowerCase(Locale.getDefault()).

I18n Issues

The zero-argument version of this method attempts to transform characters based upon the character set rules of the default locale. If it is passed character data for another locale, these characters may not fall under the rules of the default locale and will perform incorrectly. It is recommended I18n practice to instead use the method signature that explicitly sets the locale to that of the current user.

Globalyzer will detect this method and report it as an I18n issue regardless of the signature used and regardless of whether it is being used correctly. If Locale is already being passed as an argument, Globalyzer will detect it to force developers to double check that the correct Locale is being passed. If you have determined that the call is being handled correctly, you can use Globalyzer's Ignore Comment functionality to ensure that it isn't picked up in a subsequent scan.

Suggested Replacement

public String toLowerCase(Locale locale)

Instead of:

String original = getTextFromUser();
String lowerCaseString = original.toLowerCase();


//Retrieve the user's locale
Locale locale = getUserLocale();
String original = getTextFromUser();
String lowerCaseString = original.toLowerCase(locale);

Please see Case Conversion for more information.

Locale-Sensitive Java Methods


Lingoport internationalization and localization services and software