简体   繁体   English

我如何获得用户键入的非英语语言中的特殊单词的单词,包括c#,javascript

[英]How i can get the word who user type for a special word in non-english language in any language even c# , javascript

Assume that a Non-English user types Namaste Duniya. 假设非英语用户键入Namaste Duniya。 I need to show नमस्ते दुनिया in Hindi Language. 我需要用印地语显示اमस््ेदुनिया。 if i have नमस्ते दुनिया stored in a variable then how i can get the word that was typed by the user through keyboard and to show them in unicode. 如果我有一个存储在变量中的单词,那么我该如何获取用户通过键盘输入的单词并以unicode显示它们。 Like in this example namaste Duniya was typed for showing them नमस्ते दुनिया. 像在此示例中一样,键入namaste Duniya是为了向他们显示नमस््ेदुनिया。

So my question is can I convert the chars to match the word they (users) typed in the keyboard? 所以我的问题是我可以将字符转换为匹配他们(用户)在键盘上键入的单词吗? How i can do this in c# or any other language like javascript? 我如何用C#或其他任何语言(例如javascript)来做到这一点?

This one seems to handle your texts 这个似乎可以处理您的文字

http://pinyin.info/tools/converter/chars2uninumbers.html http://pinyin.info/tools/converter/chars2uninumbers.html

नमस्ते दुनिया became नमस्ते दुनिया नमस्ाेदुनिया变成了नमस्ते दुनिया नमस्ते दुनिया

The code used is quite simple: 使用的代码非常简单:

  var iString = "नमस्ते दुनिया", oString ="";
  for (var i=0; i<iString.length; i++) {
    oString += (iString.charCodeAt(i)<=127)? iString.charAt(i) : '&#' + iString.charCodeAt(i) + ';': 
  }

UPDATE: 更新:

If I understand the new text of the question, then something like 如果我理解问题的新内容,那么类似

var translateLatin2Hindi = { 
"Namaste Duniya":"नमस्ते दुनिया",
,
,

"Duniya Namaste":"दुनिया नमस्ते"
}

var translateHindi2Latin = {}
for (var o in translateLatin2Hindi) {
  translateHindi2Latin[translateLatin2Hindi[o]]=o;
}

which then can be used as 然后可以用作

function getHindi(latinString) {
  var val = translateLatin2Hindi[latinString];
  return (val)?val:"Not found";
}    
function getLatin(hindiString) {
  var val = translateHindi2Latin[hindiString];
  return (val)?val:"Not found";
}

The original question was 最初的问题是

like Hello wolrd in Hindi it's was नमस्ते दुनिया and user type in keyboard for type it is 就像印地语中的Hello wolrd一样,它是नमस्ाेियनिया,用户在键盘上输入的类型是

namaste Duniya 纳马斯特·杜尼亚(Namaste Duniya)

how i can get them namaste Duniya when i have a text नमस्ते दुनिया 当我有文字मसमसियियi i aste iya

so I guess the question is either about transliteration of Hindi, or about mapping output (Unicode) characters to key sequences on the keyboard. 所以我想这个问题是关于印地语的音译,还是关于将输出(Unicode)字符映射到键盘上的键序列。

(just a hint for those fluent in Hindi keyboard mappings) (这只是对那些精通印地语键盘映射的提示)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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