Problem with JSON conversion in C/C++ driver

Hello,
I am using the C++ driver for MongoDB data access and I have a problem with correctly extracting a JSON with the query I need.

  • I have a bsoncxx::document::view that I have obtained and I want to convert it to JSON.
  • The C++ function was giving problems with the conversion so checking in forums and the source code I found the C equivalent to doing that:
	bson_t bson;
	bson_init_static(&bson, view.data(), view.length());

	size_t size;
	char * result = bson_as_json(&bson, &size);

That’s ok and in principle, it worked fine.
My problem is that whenever the query has strings of data with special characters (ó, í, ñ, …) the JSON has converted just those characters incorrectly so I guess it is some problem with the encoding.
When I test the query in MongoDB Atlas they are always fine.
I tried also with bson_as_relaxed_extended_json / bson_as_canonical_extended_json but the problem is the same.
Any clue how I can fix that so I can recover the data strings correctly?

Thank you very much.

Daniel.