We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Klaus A.
9 years agoHelpful | Level 5
Umlauts in file names
Hi, I am using the v2 API for http. What I found is that if a file or folder name contains a special character, like a German Umlaut like ä, I get a 400 error on upload and download. Is this a bug? ...
Klaus A.
9 years agoHelpful | Level 5
I got a solution from Dropbox support that works. You need to escape all non-ASCII characters 'JSON' style. Which means all characters with character codes > 0x7F have to be replaced by a 4-digit hex code (it's hex unicode), preceeded by '\u'. For example Ä would be replaced with \u00c4 in the file name string.
Replacing parts of a string is very straightforward in Javascript, but a little more involved in a language like C.
Greg-DB
Dropbox Community Moderator
9 years agoFor example, in C#, using Json.NET/JsonTextWriter, that would look like:
var sb = new StringBuilder();
var textWriter = new JsonTextWriter(new StringWriter(sb));
textWriter.StringEscapeHandling = StringEscapeHandling.EscapeNonAscii;
// Write things to text writer
textWriter.WriteStartArray();
textWriter.WriteValue("Hello");
...
var result = sb.toString().Replace("\x7f", "\\u007f");
Or, using Json.NET/JsonConvert:
var serializerSettings = new JsonSerializerSettings();
serializerSettings.StringEscapeHandling = StringEscapeHandling.EscapeNonAscii;
var result = JsonConvert.SerializeObject(..., serializerSettings);
result = result.Replace("\x7f", "\\u007f");
- developer_net9 years agoExplorer | Level 4Thank you Klaus!
Upgrading vom Json.net 4.5 to 10 and using the StringEscapeHandling.EscapeNonAscii solves my problem ;-)
Best regards, Horst - mi29 years agoNew member | Level 2
My file path is saved in a c++ std::string. Can you please provide code to do that character skipping in C++? Thanks.
- Greg-DB9 years ago
Dropbox Community Moderator
mi2 I unfortunately don't have a sample for C++. Please refer to my C# samples above and translate them for your platform.
- Abhishek38810008 years agoNew member | Level 2
Is there any way to do this in java?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!