简体   繁体   中英

Lodash: is there a way to uppercase a word keeping accents with lodash?

Is there a lodash function that would transform "répété" => "RÉPÉTÉ" instead of "REPETE" as it's done by the uppercase function?

If not, what's an easy way to perform this in Javascript?

Well you have a native function called "toLocaleUpperCase()"

you can do this:

 const str = 'répété'; const ret = str.toLocaleUpperCase(); alert(ret);

docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase

You could use toLocaleUpperCase()

 const str = 'répété'; const ret = str.toLocaleUpperCase(); console.log(ret);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM