【发布时间】:2010-07-23 14:21:21
【问题描述】:
我有一个应用程序在 UI 元素中使用托管 System::String,但随后引用非托管(阅读:遗留)代码进行更复杂的计算。
此外,字符串没有一致的编码 - 托管字符串可以是常规的 "strings" 或 Unicode L"strings",非托管字符串有所有 char *, wchar_t *, std::string, std::wstring 变体。
比较不同风格的弦乐的最佳方法是什么?我希望我可以做到这一点,而不必实现像
这样的六种比较方法int compare(System::String ^ s1, char * s2);
int compare(System::String ^ s1, wchar_t * s2);
int compare(System::String ^ s1, std::string s2);
int compare(System::String ^ s1, std::wstring s2);
int compare(char * s1, System::String ^ s2);
int compare(wchar_t * s1, System::String ^ s2);
...
主要目的是进行相等比较,所以如果这些比较容易做到,那么我也希望看到这些答案。
【问题讨论】:
标签: string visual-c++ .net-2.0