使用javascript组合unicode字符
combine unicode characters using javascript
我可以使用这个
分割unicode字符function myFunction() {
var str = "कसौटी";
var res = str.split("");
document.getElementById("demo").innerHTML = res;
但是它像这样分割所有的字符
क,स,ौ,ट,ी
如何合并स,ौ
得到सौ
和ट,ी
得到टी
问题是我想先拆分字符然后重新连接,这些是印度语中的连词,需要这样显示
您需要为印地语字符创建一个unicode字典,这里是完整表的链接,这里是您如何在代码中完成它:
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
var theDictionary = {''u0bbf':true,''u0bcd':true,...}; //example of unicode, add yours
var temporaryList ="कसौटी".split('');
var targetList = [];
for(var index in temporaryList ){
if(theDictionary [temporaryList [index]])
{
targetList[targetList.length - 1] += temporaryList [index];
}
else
{
targetList.push(temporaryList [index]);
}
}
}
</script>
</head>
<body>
<h1>My Web Page</h1>
<p id="demo">A Paragraph</p>
<button type="button" onclick="myFunction()">Try it</button>
</body>
</html>
请记住,必须创建字典,否则它将无法工作,因为没有它,印地语字符串将无法识别。
相关文章:
- 无法呈现js unicode字符“u1F310”
- Unicode字符未在HTML5画布中正确呈现
- jquery textcomplete无法使用Unicode字符,并且缺少空格
- JavaScript Unicode Regex - 字符类中的顺序范围
- 在 Javascript 中显示 unicode 字符(表情符号)
- 请求返回 unicode 替换字符
- 将文本和html unicode字符添加到textarea元素中
- 用unicode字符提取字符串中的单词
- 如何替换不可打印的unicode字符(Javascript)
- PHP:如何用unicode字符将文件写入磁盘
- 替换不包括 unicode 的非数字字符
- JavaScript 转到带有 Unicode 字符的 URL
- 为什么这个 unicode 字符的警报不成功
- 如何在包含 Unicode 字符 'u00A0' 的表中包装单词
- Mozilla Builder 编辑器取消转义 Unicode 字符,并发 w. AMO 上传失败
- 正则表达式匹配所有单词,包括标点符号和 unicode 字符.没有空格
- 正则表达式与专业 unicode 字符不匹配
- 使用带有 unicode 字符的 ng-pattern (Angular.JS) 的不良结果
- 删除不受支持的 unicode 字符,否则显示为正方形
- Javascript:非 unicode 字符代码到 unicode 字符