What is the correct way to encode the strings into the Azure Blob Metadata?
When using Azure Storage Explorer, it seems to use a function close to C# UWPs WebUtiliy.UrlEncode
. But unfortunately WebUtilty.UrlEncode replaces the empty spaces with "+" signs (Storage Explorer keeps the spaces as is)
Is there any other builtin encoding method so I can keep compatibility of my metadata between my application and the Storage Explorer?
Thanks
In generally, we don't need to encode the value unless any name/value pairs contain non-ASCII characters. It is therefore recommended that you use URL encoding or Base64 encoding for names and values containing non-ASCII characters.
You could use any ways you want since you could decode the string correctly. The tool will not have influences on the way you are encoding and decoding. No matter how the value showed in Storage Explorer UI, the value you got from app is the encoded string by you.
If you do want use the same encode/decode way with Storage Explorer, by testing on my side, you could try to use Uri.EscapeUriString
method. This encode the space to %20
and Storage Explorer can correctly decode.
string escapetest= Uri.EscapeDataString(specialvalue);
blockBlob.Metadata["category"] = escapetest;