javascript - toLocaleLowerCase() 的使用
问题描述
我正在使用toLocaleLowerCase()
拉丁字符。拉丁字符是“Ö”。拳头我对其进行编码,然后尝试使用toLocaleLowerCase()
. 似乎,它没有给我正确的小写字符
const encodedText: string = encodeURIComponent("Å"); --> value is "%C3%85"
const lowerCaseText: string = encodedText.toLocaleLowerCase(); --> value is "%c3%85". But it should be "%C3%A5"
这里有什么问题?
它与浏览器语言环境有关吗?
我怎样才能解决这个问题?
解决方案
你正在做的事情的顺序是错误的。
您想要的是先使用toLocaleLowerCase
,然后才使用encodeURIComponent
. 否则,它将更改编码字符串的大小写,而不是字符串本身。
var char = "Å";
console.log(encodeURIComponent(char));
var lowerCaseChar = char.toLocaleLowerCase();
console.log(encodeURIComponent(lowerCaseChar));
推荐阅读
- winapi - 具有透明背景的win32菜单项位图
- python - 将文本转换为列或数据框或其他文本
- python - Python NameError:未定义名称“X”
- python-3.x - Python 3 中的多线程 Ping 脚本
- azure-functions - 共享环境中的功能/应用程序服务内存不受探测文档的影响 - 跨租户黑客
- c# - datatables asp.net core razor pages IActionResult new JsonResult
- bash - 在 dockerfile 中加载 2 个进程?
- angular - 角度选择元素的 ngModel 不正确
- c# - 事件流和事件溯源
- time-complexity - theta(1) 在 n 次的总和是 theta(log n base 2)