Skip to content

Commit b0f2ca2

Browse files
authored
Merge pull request #4 from Hugoberry/utf-8
Support for Wide-characters in column names
2 parents a01189b + b03145e commit b0f2ca2

File tree

3 files changed

+31
-37
lines changed

3 files changed

+31
-37
lines changed

src/msolap_utils.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,15 @@
33
namespace duckdb {
44

55
std::string MSOLAPUtils::SanitizeColumnName(const std::wstring &name) {
6-
std::string result;
7-
result.reserve(name.size());
8-
9-
for (size_t i = 0; i < name.size(); i++) {
10-
// Replace brackets with underscores as required
11-
if (name[i] == L'[' || name[i] == L']') {
12-
result += '_';
13-
} else if (name[i] <= 255) {
14-
// Convert to ASCII if possible
15-
result += static_cast<char>(name[i]);
16-
} else {
17-
// Replace non-ASCII with underscore
18-
result += '_';
6+
std::wstring sanitized = name;
7+
for (size_t i = 0; i < sanitized.size(); i++) {
8+
if (sanitized[i] == L'[' || sanitized[i] == L']') {
9+
sanitized[i] = L'_';
1910
}
2011
}
2112

22-
return result;
13+
// Convert the entire string to UTF-8 properly
14+
return WindowsUtil::UnicodeToUTF8(sanitized.c_str());
2315
}
2416

2517
Value MSOLAPUtils::ConvertVariantToValue(VARIANT* pVar) {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# name: test/sql/msolap_table_constructor.test
2+
# description: test msolap extension with DAX table constructor
3+
# group: [msolap]
4+
5+
# Require statement will ensure this test is run with the extension loaded
6+
require msolap
7+
8+
# Test German special characters in column names and contents
9+
query II
10+
FROM msolap(
11+
'Provider=MSOLAP;Data Source=localhost:54043;Catalog=53e9bf8c-d0e3-49c8-818c-3505753645bd',
12+
'EVALUATE
13+
DATATABLE( "🦆", STRING, "äöü", STRING,
14+
{
15+
{"Duck", "DB"},
16+
{"Straße", "äöü"},
17+
{"München", "Köln"},
18+
{"Jürgen", "Größe"}
19+
})'
20+
);
21+
----
22+
Straße äöü
23+
München Köln
24+
Jürgen Größe
25+

test/sql/quack.test

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)