String.prototype.toLocaleUpperCase()

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

Syntax

str.toLocaleUpperCase()
str.toLocaleUpperCase(locale)
str.toLocaleUpperCase([locale, locale, ...])

Parameters

locale Optional
The locale parameter indicates the locale to be used to convert to upper case according to any locale-specific case mappings. If multiple locales are given in an Array, the best available locale is used. The default locale is the host environment’s current locale.

Return value

A new string representing the calling string converted to upper case, according to any locale-specific case mappings.

Exceptions

  • A RangeError ("invalid language tag: xx_yy") is thrown if a locale argument isn't a valid language tag.
  • A TypeError ("invalid element in locales argument") is thrown if an array element isn't of type string.

Description

The toLocaleUpperCase() method returns the value of the string converted to upper case according to any locale-specific case mappings. toLocaleUpperCase() does not affect the value of the string itself. In most cases, this will produce the same result as toUpperCase(), but for some locales, such as Turkish, whose case mappings do not follow the default case mappings in Unicode, there may be a different result.

Also notice that conversion is not necessarily a 1:1 character mapping, as some characters might result in two (or even more) characters when transformed to upper-case. Therefore the length of the result string can differ from the input length. This also implies that the conversion is not stable, so i.E. the following can return false:
x.toLocaleLowerCase() === x.toLocaleUpperCase().toLocaleLowerCase()

Examples

Using toLocaleUpperCase()

'alphabet'.toLocaleUpperCase(); // 'ALPHABET'

'Gesäß'.toLocaleUpperCase(); // 'GESÄSS'

'i\u0307'.toLocaleUpperCase('lt-LT'); // 'I'

let locales = ['lt', 'LT', 'lt-LT', 'lt-u-co-phonebk', 'lt-x-lietuva'];
'i\u0307'.toLocaleUpperCase(locales); // 'I'

Specifications

Specification
ECMAScript (ECMA-262)
The definition of 'String.prototype.toLocaleUpperCase' in that specification.
ECMAScript Internationalization API (ECMA-402)
The definition of 'String.prototype.toLocaleUpperCase' in that specification.

Browser compatibility

DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
toLocaleUpperCaseChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 5.5Opera Full support 4Safari Full support 1.3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
localeChrome Full support 58Edge Full support 12Firefox Full support 55IE Full support 6Opera Full support 45Safari Full support 10WebView Android Full support 58Chrome Android Full support 58Firefox Android Full support 55Opera Android Full support 42Safari iOS Full support 10Samsung Internet Android Full support 7.0nodejs Full support 13.0.0
Full support 13.0.0
Partial support 0.12
Notes
Notes Before version 13.0.0, only the locale data for en-US is available by default. When other locales are specified, the function silently falls back to en-US. To make full ICU (locale) data available for versions prior to 13, see Node.js documentation on the --with-intl option and how to provide the data.

Legend

Full support
Full support
See implementation notes.
See implementation notes.

See also