Support unicode APIs for LabVIEW
This commit is contained in:
@@ -893,9 +893,40 @@ extern "C" ANSULT_API int ANSDecodeJsonUnicodeToUTF16LE(const char* escapedStr,
|
||||
catch (...) { return -1; }
|
||||
}
|
||||
|
||||
extern "C" ANSULT_API int ANSConvertUTF16LEToUnicodeEscapes(const unsigned char* utf16leBytes, int byteLen, LStrHandle result) {
|
||||
try {
|
||||
if (!utf16leBytes || byteLen <= 0 || !result) return -1;
|
||||
std::string escaped = ANSCENTER::ANSUtilities::ConvertUTF16LEToUnicodeEscapes(
|
||||
reinterpret_cast<const char*>(utf16leBytes), byteLen);
|
||||
if (escaped.empty()) return 0;
|
||||
int size = static_cast<int>(escaped.size());
|
||||
MgErr error = DSSetHandleSize(result, sizeof(int32) + size * sizeof(uChar));
|
||||
if (error != noErr) return -2;
|
||||
(*result)->cnt = size;
|
||||
memcpy((*result)->str, escaped.data(), size);
|
||||
return 1;
|
||||
}
|
||||
catch (...) { return -1; }
|
||||
}
|
||||
|
||||
extern "C" ANSULT_API int ANSConvertUnicodeEscapesToUTF8(const char* escapedStr, LStrHandle result) {
|
||||
try {
|
||||
if (!escapedStr || !result) return -1;
|
||||
int len = (int)strlen(escapedStr);
|
||||
if (len == 0) return 0;
|
||||
std::string utf8 = ANSCENTER::ANSUtilities::ConvertUnicodeEscapesToUTF8(escapedStr);
|
||||
if (utf8.empty()) return 0;
|
||||
int size = static_cast<int>(utf8.size());
|
||||
MgErr error = DSSetHandleSize(result, sizeof(int32) + size * sizeof(uChar));
|
||||
if (error != noErr) return -2;
|
||||
(*result)->cnt = size;
|
||||
memcpy((*result)->str, utf8.data(), size);
|
||||
return 1;
|
||||
}
|
||||
catch (...) { return -1; }
|
||||
}
|
||||
|
||||
// AWSS3
|
||||
// AWSS3
|
||||
extern "C" ANSULT_API int CreateANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, const char* licenseKey) {
|
||||
if (Handle == nullptr || licenseKey == nullptr) return 0;
|
||||
if (*Handle) {
|
||||
|
||||
Reference in New Issue
Block a user