-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathunix_utils.h
More file actions
33 lines (25 loc) · 1.05 KB
/
unix_utils.h
File metadata and controls
33 lines (25 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// This header defines utility functions for safely handling SQLWCHAR-based
// wide-character data in ODBC operations on macOS. It includes conversions
// between SQLWCHAR, std::wstring, and UTF-8 strings to bridge encoding
// differences specific to macOS.
#pragma once
#include <codecvt>
#include <locale>
#include <pybind11/pybind11.h>
#include <sql.h>
#include <sqlext.h>
#include <string>
#include <vector>
namespace py = pybind11;
#if defined(__APPLE__) || defined(__linux__)
// Constants for character encoding
extern const char* kOdbcEncoding; // ODBC uses UTF-16LE for SQLWCHAR
extern const size_t kUcsLength; // SQLWCHAR is 2 bytes on all platforms
// Function to convert SQLWCHAR strings to std::wstring on macOS
// Removed default argument to avoid redefinition conflict
std::wstring SQLWCHARToWString(const SQLWCHAR* sqlwStr, size_t length);
// Function to convert std::wstring to SQLWCHAR array on macOS
std::vector<SQLWCHAR> WStringToSQLWCHAR(const std::wstring& str);
#endif