简体   繁体   English

比较两种语言字符串

[英]Compare two language strings

We are working on a remote manmagment software. 我们正在开发一个远程监控软件。 We require to compare the data we get from the remote system. 我们需要比较从远程系统获得的数据。 We are using C++ and WMI to get data from remote system. 我们正在使用C ++和WMI从远程系统获取数据。 WHen processing the data we may need to compare certain words (against constant words we have) from the data collected from remote system. 在处理数据时,我们可能需要比较从远程系统收集的数据中的某些单词(相对于我们拥有的常量单词)。 When the host and target systems are in English language, we have no issues in compare the strings. 当主机系统和目标系统使用英语时,比较字符串就没有问题。

But when the remote computer returns data other than english, our comparision is failed. 但是,当远程计算机返回英语以外的数据时,我们的比较失败了。 We thought of implementing localization and keep all possible language strings with us, . 我们考虑实施本地化,并保留所有可能的语言字符串。 And if, one of the strings in our list maches, we can proceed. 并且,如果列表中的字符串之一匹配,我们可以继续。 But it is very tedious process. 但这是一个非常繁琐的过程。

Is there any way to compare strings from two differnt languages in C++ or WMI...? 有什么方法可以比较C ++或WMI中两种不同语言的字符串吗?

Any APIs..? 任何API ..? OR Workarounds...? 或解决方法...?

Please help! 请帮忙!

There are c# facilities for comparing strings in a locale, or culture-specific way, see this which gives an example of a comparison between two german strings treating the different representations of "ss" and the essettz character 'ß'as equivalent. 有在一个区域或特定文化的方式比较字符串C#设施,看到这给两个德国字符串处理“SS”和essettz字符“ß'as等价的不同表示之间的比较的例子。

To do this you need to have knowledge of the language of the host computer, it's debatable if you should treat ss and 'ß'as equal if you are not working in German. 为此,您需要了解主机的语言,如果您不使用德语工作,则应将ss和“ß”等同地对待是有争议的。

But I'm not clear to whether you have this kind of problem. 但是我不清楚您是否有这种问题。 Are you in fact hoping to actually translate the text you receive? 您实际上是否真的希望翻译收到的文本? So on you machine you have a list of strings: 因此,在您的计算机上,您有一个字符串列表:

RED
GREEN
WHITE

and you might receive from the host RED or ROUGE or ROT. 并且您可能会从主机收到RED或ROUGE或ROT。 In which case I don't really see you have much option but to keep a translation table. 在这种情况下,我看不到您有太多选择,只能保留翻译表。

You should use std::locale and its various features ( operator() ). 您应该使用std :: locale及其各种功能( operator() )。 I suppose you also want to use std::wstring instead of usual std::string to support UTF-like characters. 我想您还想使用std :: wstring代替通常的std :: string来支持类似UTF的字符。

I think you're looking for Windows Management Instrumentation: International Support Overview . 我认为您正在寻找Windows Management Instrumentation:国际支持概述 The need for localization, and the resulting need for cross-locale support has been noted before. 以前已经指出了本地化的需求以及由此产生的对跨语言环境的支持。

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

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