toLocaleUpperCase()
method returns the calling string value converted to upper case, according to any locale-specific case mappings.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
str.toLocaleUpperCase() str.toLocaleUpperCase(locale) str.toLocaleUpperCase([locale, locale, ...])
locale
可选
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
,
best available locale
is used. The default locale is the host environment’s current locale.
A new string representing the calling string converted to upper case, according to any locale-specific case mappings.
RangeError
("invalid language tag: xx_yy") is thrown if a
locale
argument isn't a valid language tag.
TypeError
("invalid element in locales argument") is thrown if an array element isn't of type string.
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()
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'
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
更新 GitHub 上的兼容性数据| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toLocaleUpperCase
|
Chrome 1 | Edge 12 | Firefox 1 | IE 5.5 | Opera 4 | Safari 1.3 | WebView Android 1 | Chrome Android 18 | Firefox Android 4 | Opera Android 10.1 | Safari iOS 1 | Samsung Internet Android 1.0 | nodejs 0.1.100 |
locale
|
Chrome 58 | Edge 12 | Firefox 55 | IE 6 | Opera 45 | Safari 10 | WebView Android 58 | Chrome Android 58 | Firefox Android 55 | Opera Android 42 | Safari iOS 10 | Samsung Internet Android 7.0 |
nodejs
13.0.0
|
完整支持
见实现注意事项。
String
String.fromCharCode()
String.fromCodePoint()
String.prototype.anchor()
String.prototype.big()
String.prototype.blink()
String.prototype.bold()
String.prototype.charAt()
String.prototype.charCodeAt()
String.prototype.codePointAt()
String.prototype.concat()
String.prototype.endsWith()
String.prototype.fixed()
String.prototype.fontcolor()
String.prototype.fontsize()
String.prototype.includes()
String.prototype.indexOf()
String.prototype.italics()
String.prototype.lastIndexOf()
String.prototype.link()
String.prototype.localeCompare()
String.prototype.match()
String.prototype.matchAll()
String.prototype.normalize()
String.prototype.padEnd()
String.prototype.padStart()
String.prototype.repeat()
String.prototype.replace()
String.prototype.replaceAll()
String.prototype.search()
String.prototype.slice()
String.prototype.small()
String.prototype.split()
String.prototype.startsWith()
String.prototype.strike()
String.prototype.sub()
String.prototype.substr()
String.prototype.substring()
String.prototype.sup()
String.prototype.toLocaleLowerCase()
String.prototype.toLocaleUpperCase()
String.prototype.toLowerCase()
String.prototype.toSource()
String.prototype.toString()
String.prototype.toUpperCase()
String.prototype.trim()
String.prototype.trimEnd()
String.prototype.trimStart()
String.prototype.valueOf()
String.prototype[@@iterator]()
String.raw()
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()