Support UTF8 to UTF16 LE

This commit is contained in:
2026-03-31 14:10:21 +11:00
parent 0c24096c80
commit 70be68d0fc
14 changed files with 790 additions and 11 deletions

View File

@@ -660,6 +660,17 @@ namespace ANSCENTER
static std::string PolygonToString(const std::vector<cv::Point2f>& polygon);
static std::string KeypointsToString(const std::vector<float>& kps);
static std::vector<cv::Point2f> RectToNormalizedPolygon(const cv::Rect& rect, float imageWidth, float imageHeight);
// Convert a UTF-8 encoded string to UTF-16LE byte string.
// Useful for LabVIEW which can display UTF-16LE Unicode text on Windows.
// Returns a std::string containing the raw UTF-16LE bytes (2 bytes per character).
static std::string ConvertUTF8ToUTF16LE(const std::string& utf8Str);
// Decode JSON Unicode escape sequences (\uXXXX) to UTF-16LE byte string.
// Input: ASCII string with \uXXXX escapes (e.g., "\\u6c5f\\u6771 599")
// Output: UTF-16LE byte string for LabVIEW display.
// ASCII characters pass through as 2-byte UTF-16LE (e.g., 'A' -> 0x41 0x00).
static std::string DecodeJsonUnicodeToUTF16LE(const std::string& escapedStr);
static std::vector<cv::Point2f> MaskToNormalizedPolygon(const cv::Mat& binaryMask, const cv::Rect& boundingBox, float imageWidth, float imageHeight, float simplificationEpsilon = 2.0f, int minContourArea = 10, int maxPoints = 50);
};
@@ -1142,4 +1153,8 @@ namespace ANSCENTER
};
}
// Unicode conversion utilities for LabVIEW wrapper classes
extern "C" ANSENGINE_API int ANSEngine_ConvertUTF8ToUTF16LE(const char* utf8Str, LStrHandle result);
extern "C" ANSENGINE_API int ANSEngine_ConvertUTF16LEToUTF8(const unsigned char* utf16leBytes, int byteLen, LStrHandle result);
#endif