Skip to content

Commit 8dfc597

Browse files
mikeferompenick
authored andcommitted
CPP-807 - Handle varying encoded UTF configuration files (#281)
1 parent 927b64a commit 8dfc597

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

cpp-driver/src/cloud_secure_connection_config.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@ bool CloudSecureConnectionConfig::load(const String& filename, Config* config /*
237237
return false;
238238
}
239239

240+
json::MemoryStream memory_stream(contents.c_str(), contents.size());
241+
json::AutoUTFMemoryInputStream auto_utf_stream(memory_stream);
240242
json::Document document;
241-
document.Parse(contents.c_str());
243+
document.ParseStream(auto_utf_stream);
242244
if (!document.IsObject()) {
243245
LOG_ERROR(CLOUD_ERROR "Invalid configuration");
244246
return false;

cpp-driver/src/json.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ class Allocator {
7373

7474
typedef datastax::rapidjson::UTF8<> UTF8;
7575
typedef datastax::rapidjson::MemoryPoolAllocator<json::Allocator> MemoryPoolAllocator;
76+
typedef datastax::rapidjson::MemoryStream MemoryStream;
7677

7778
typedef datastax::rapidjson::GenericDocument<UTF8, MemoryPoolAllocator, json::Allocator> Document;
7879
typedef datastax::rapidjson::GenericValue<UTF8, MemoryPoolAllocator> Value;
7980
typedef datastax::rapidjson::GenericStringBuffer<UTF8, json::Allocator> StringBuffer;
81+
typedef datastax::rapidjson::AutoUTFInputStream<unsigned, MemoryStream> AutoUTFMemoryInputStream;
8082

8183
template <typename OutputStream, typename SourceEncoding = UTF8, typename TargetEncoding = UTF8,
8284
typename StackAllocator = json::Allocator,

0 commit comments

Comments
 (0)