String.prototype.toLocaleUpperCase()
String 值的 toLocaleUpperCase() 方法返回根据任何特定于区域设置的大小写映射转换为大写的字符串。
¥The toLocaleUpperCase() method of String values returns this string converted to upper case, according to any locale-specific case mappings.
Try it
语法
参数
¥Parameters
localesOptional-
带有 BCP 47 语言标记的字符串,或此类字符串的数组。指示根据任何特定于区域设置的大小写映射用于转换为大写的区域设置。有关
locales论证的一般形式和解释,请参阅Intl主页参数说明。与使用
locales参数的其他方法不同,toLocaleUpperCase()不允许区域设置匹配。因此,在检查locales参数的有效性后,toLocaleUpperCase()始终使用列表中的第一个区域设置(如果列表为空,则使用默认区域设置),即使实现不支持此区域设置。
返回值
描述
¥Description
toLocaleUpperCase() 方法返回根据任何特定于区域设置的大小写映射转换为大写的字符串值。toLocaleUpperCase() 不影响字符串本身的值。在大多数情况下,这将产生与 toUpperCase() 相同的结果,但对于某些区域设置(例如土耳其语),其大小写映射不遵循 Unicode 中的默认大小写映射,可能会产生不同的结果。
¥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.
另请注意,转换不一定是 1:1 字符映射,因为某些字符在转换为大写时可能会产生两个(甚至更多)字符。因此,结果字符串的长度可能与输入长度不同。这也意味着转换不稳定,所以即以下可以返回 false:x.toLocaleLowerCase() === x.toLocaleUpperCase().toLocaleLowerCase()
¥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()
规范
| Specification |
|---|
| ECMAScript Language Specification # sec-string.prototype.tolocaleuppercase |
| ECMAScript Internationalization API Specification # sup-string.prototype.tolocaleuppercase |
浏览器兼容性
BCD tables only load in the browser