That I don't know about precisely. But I do know that you have to encode everything the same all the way through the process, through generating the data, to its storage and retrieval, and to presentation. Otherwise you will have to convert or strip at certain points, perhaps losing data in the process.
Also, I just realized, I gave you bad advice on the replace, not using a regular expression will only get rid of the first instance of the thing to be replaced, and, since you're already using a regular expression, you should be able to combine them:
Code:
filename = filename.replace(/\s+|'/g, '');
If you also want to also get rid of all those odd looking characters, try:
Code:
filename = filename.replace(/\s+|[^0-z]/g, '')
which will still also remove ' , and will also remove " - if you want to keep " do:
Code:
filename = filename.replace(/\s+|[^0-z"]/g, '')
But a better option might be:
Code:
filename = filename.replace(/\W/g, '')
which gets rid of everything that's not a word character or a number.
Bookmarks