Forum Discussion

Adam B.'s avatar
Adam B.
Explorer | Level 3
7 years ago
Solved

Problem with special charachters in Company name

I'm working on an internal production tool for our company. And for that I need to compare some local files inside the Dropbox folder with the files synced to Dropbox (to at least try to prevent som race conditions working with InDesign and the lock-files created by it).

And then I use the path info from ~/.dropbox/info.json to get at which path the team folder is mounted.

But I encounter a problem when using the path because there seems to be some differences between how Dropbox parses special characters and how macOS treats them.

In our case it's "ö" – parsed as "o\u0308" in info.json, but I'm guessing there might be some trouble with similar characters such as "å", "ä" or "ü". And if I want to distribute this to a larger crowd I have to account for this.

When I compare the the specific charachters retrieved using String.prototype.charCodeAt(), the difference get clear:

OS path: charCode 111
Dropbox path: charCode 246

And in the file the name of our company is "Sjo\u0308fartstidningen".

Maybe it's Dropbox, or maybe this has something to do with how javascript parses "o\u0308", I don't now. I just did JSON.parse(content) after retrieving the content of info.json using fs.readFile(path, 'utf8'). Has anyone else encountered this? Does anyone know of a way to properly parse unicode charachters with Node? Or is there actually a difference between how Dropbox does this and how macOS does it?

  • Adam B.'s avatar
    Adam B.
    Explorer | Level 3

    Okey I've digged a bit deeper into this. It seems like Dropbox have interpreted the "ö" in "Sjöfartstidningen" (our company) as o + "¨" (well not really ¨ but a similar char) separateley. Which equals "o\u0308", instead I would expect "\u00f6".

    I've got this from https://www.branah.com/unicode-converter

    But this doesn't make me any smarter...

      • Adam B.'s avatar
        Adam B.
        Explorer | Level 3

        Hi, yeah thanks for your answer! Five minutes before leaving work yesterday I stumbled upon the String.prototype.normalize()-function and it very easily solved my problems!

        For future reference and to anyone that might stumble upon this:

        As I've understood it, while searching through sources, there are two ways to represent charachters such as å, ä, ö and similar in a unicode string. Either as one special charachter (e.g. 'ö' === '\u00f6' in JS) or as a base charachter together with a combining diaeresis (e.g. 'ö' === 'o\u0308' in JS).

        In javascript one can use String.prototype.normalize() to compare two strings even if the strings use different solutions to store charachters.

        Please correct me if I'm wrong.

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with other developers804 PostsLatest Activity: 9 hours ago
217 Following

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 or Facebook.

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!