JavaScript String toLocaleUpperCase() Method

JavaScript String toLocaleUpperCase() is a built-in method that returns a new string where all the characters are converted to uppercase according to the current locale’s rules. This method is beneficial when dealing with language-specific case mappings not covered by the regular toUpperCase() method.




The locale parameter is optional and indicates a locale to convert to the upper case according to any locale-specific case mappings if multiple locales are given in an Array.


let data = 'brōkən';



Javascript String ToLocaleUpperCase() Tutorial

The toLocaleUpperCase() method returns a value of the string converted to the upper case according to any locale-specific case mappings.

The toLocaleUpperCase() does not affect the value of a string itself. In most cases, it will produce the same outcome as toUpperCase(), but for some locales, such as Turkish, whose case mappings do not follow default case mappings in the Unicode, there may be a different outcome.

Also, notice that conversion is not necessarily the 1:1 character mapping, as some characters might result in two or even more characters when transformed to the upper case.

Therefore the length of the result string can differ from an input length. Unfortunately, this also implies that the conversion is not stable; for example, the following code can return the false:

x.toLocaleLowerCase() === x.toLocaleUpperCase().toLocaleLowerCase()

See the following examples.




let locales = ['lt', 'LT', 'lt-LT', 'lt-u-co-phonebk', 'lt-x-lietuva'];



String ToLocaleUpperCase() Tutorial With Example

That’s it for this tutorial.

Related posts

JavaScript toLowerCase

JavaScript toLocaleLowerCase

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.