cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with special charachters in Company name

Problem with special charachters in Company name

Adam B.
Explorer | Level 3
Go to solution

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?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

It sounds like the different strings you're trying to use have different normalization forms, and so they aren't equivalent. You should probably normalize them before comparing them, such as covered here for Node.js. Hope this helps! 

View solution in original post

3 Replies 3

Adam B.
Explorer | Level 3
Go to solution

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

Greg-DB
Dropbox Staff
Go to solution

It sounds like the different strings you're trying to use have different normalization forms, and so they aren't equivalent. You should probably normalize them before comparing them, such as covered here for Node.js. Hope this helps! 

Adam B.
Explorer | Level 3
Go to solution

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.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Adam B. Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?