Fix mixed UTF16 issue (LabVIEW) and fix ANSFR for Intel
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "LabVIEWHeader/extcode.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "ANSLicense.h"
|
||||
#include <CkRest.h>
|
||||
#include "CkAuthGoogle.h"
|
||||
@@ -118,6 +119,19 @@ namespace ANSCENTER {
|
||||
// Useful for encoding Unicode text into JSON-safe ASCII.
|
||||
static std::string ConvertUTF8ToUnicodeEscapes(const std::string& utf8Str);
|
||||
|
||||
// Repair mixed-encoding input from LabVIEW text controls.
|
||||
// LabVIEW may produce a mix of UTF-16LE pairs and UTF-8 multi-byte
|
||||
// sequences in a single byte stream. It may also insert space (0x20) as
|
||||
// a single byte without the 0x00 high byte.
|
||||
// This function normalizes everything to proper UTF-16LE pairs.
|
||||
// Input: raw bytes from LStrHandle (BOM should already be stripped).
|
||||
// Output: clean UTF-16LE with proper 2-byte alignment.
|
||||
static std::vector<unsigned char> RepairLabVIEWUTF16LE(const unsigned char* data, int len);
|
||||
|
||||
// Check if a byte sequence is valid UTF-8.
|
||||
// Returns true if all bytes form valid UTF-8 sequences.
|
||||
static bool IsValidUTF8(const unsigned char* data, int len);
|
||||
|
||||
// Double-escape \uXXXX sequences: \u1ee7 becomes \\u1ee7.
|
||||
// Useful when the string will be embedded in JSON and the literal \uXXXX must survive parsing.
|
||||
static std::string DoubleEscapeUnicode(const std::string& str);
|
||||
@@ -276,6 +290,9 @@ extern "C" ANSULT_API int ANSDecodeJsonUnicodeToUTF16LE(const char* escapedStr,
|
||||
extern "C" ANSULT_API int ANSConvertUTF16LEToUTF8(const unsigned char* utf16leBytes, int byteLen, LStrHandle result);
|
||||
extern "C" ANSULT_API int ANSConvertUTF16LEToUnicodeEscapes(const unsigned char* utf16leBytes, int byteLen, LStrHandle result);
|
||||
extern "C" ANSULT_API int ANSConvertUnicodeEscapesToUTF8(const char* escapedStr, LStrHandle result);
|
||||
// LStrHandle-safe versions: input is LStrHandle (preserves null bytes in UTF-16LE data)
|
||||
extern "C" ANSULT_API int ANSConvertUTF16LEToUTF8_LV(LStrHandle input, LStrHandle result);
|
||||
extern "C" ANSULT_API int ANSConvertUTF16LEToUnicodeEscapes_LV(LStrHandle input, LStrHandle result);
|
||||
extern "C" ANSULT_API int ANSConvertUTF8ToUnicodeEscapes(const char* utf8Str, LStrHandle result);
|
||||
extern "C" ANSULT_API int ANSDoubleEscapeUnicode(const char* str, LStrHandle result);
|
||||
extern "C" ANSULT_API int ANSConvertUTF8ToDoubleEscapedUnicode(const char* utf8Str, LStrHandle result);
|
||||
|
||||
Reference in New Issue
Block a user