首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

string.toLocaleUpperCase

toLocaleUpperCase()?使用本地化(locale-specific)的大小写映射规则将输入的字符串转化成大写形式并返回结果字符串。

语法

代码语言:javascript
复制
str.toLocaleUpperCase()
str.toLocaleUpperCase(locale) 
str.toLocaleUpperCase([locale, locale, ...])

参数

locale可选,locale参数指示根据任何语言环境特定的大小写映射转换为大写的语言环境。如果有多个语言环境在给定的Array,在最好的语言环境中使用。默认语言环境是主机环境的当前语言环境。

返回值

一个新的字符串,即根据本地化的大小写映射规则将输入的字符串转化成大写形式的结果。

异常

  • RangeError(“无效的语言标签:xx_yy”)如locale参数不是一个有效的语言标记。

  • TypeError ("“无效的元素标签:xx_yy”") i如果array不是字符串类型

描述

toLocaleUpperCase() 方法返回的是将输入的字符串根据本地化的大小写映射规则转化成的大写形式的新字符串。toLocaleUpperCase()?不会影响输入的字符串本身的值. 大多数情况下,这个方法与?toUpperCase() 会产生相同的值,但是对于一些语言(locale),例如土耳其语,因为它们的大小写映射规则与Unicode默认的映射规则不同,所以调用这两个方法将会产生不同的结果。

例子

使用toLocaleUpperCase()

代码语言:javascript
复制
'alphabet'.toLocaleUpperCase(); // 'ALPHABET'

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

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

规范

Specification

Status

Comment

ECMAScript 3rd Edition (ECMA-262)

Standard

Initial definition. Implemented in JavaScript 1.2.

ECMAScript 5.1 (ECMA-262)The definition of 'String.prototype.toLocaleUpperCase' in that specification.

Standard

?

ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'String.prototype.toLocaleUpperCase' in that specification.

Standard

?

ECMAScript Latest Draft (ECMA-262)The definition of 'String.prototype.toLocaleUpperCase' in that specification.

Draft

?

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

Draft

ES Intl 2017 added the locale parameter.

浏览器兼容性

Feature

Chrome

Firefox

Edge

Internet Explorer

Opera

Safari

Basic Support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

locale

?

55

?

?

?

?

Feature

Android

Chrome for Android

Edge mobile

Firefox for Android

IE mobile

Opera Android

iOS Safari

Basic Support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

locale

?

?

?

55

?

?

?

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com