Reputation: 2441
I have a problem with encoding of some characters when storing data in Azure Cosmos DB graph.
For example, if I execute a query like this to add a new vertex with name Stéphane:
g.addV('test-encoding').property('id','some id').property('name','Stéphane')
It shows up in Azure Portal's Data Explorer as Stéphane. If I try to query the vertex from Gremlin command line I don't get the correct value for name returned either.
So it seems that I have problem with encoding of the data in Cosmos DB.
In another question it was suggested to Url encode the data before creating the vertex and then Url decode it when it needs to be read.
That however feels cumbersome and I am wondering if there is something else that can be done to store strings with correct encoding?
Upvotes: 4
Views: 2718
Reputation: 71
Your query is right. The property value is actually correctly saved in CosmosDB (with the correct accent).
This is a rendering bug in the portal's Data Explorer: when querying CosmosDB, Data Explorer doesn't properly decode the response when it contains these two-bytes utf-8 characters and will show 2 distinct characters instead of one, in the Graph UI tab and also the JSON tab in Data Explorer. A fix is coming in the next deployment of the Data Explorer.
If you are using the CosmosDB SDK or the gremlin console, you can query your graph directly and verify that "Stéphane" is correctly stored.
Upvotes: 4