Please specify what version of the library you are using: [1.0.3]
I'm trying to synchronize files with a service that allows all characters in the filename. To get around the forbidden characters, I'm replacing the forbidden ones with Unicode lookalikes: " ﹡ / ﹕ ﹤ ﹥ ﹖ \ │.
When I'm then uploading files with this new name, the unicode is replaced with U.
sp.web.getFolderByServerRelativePath(path).files.addChunked(filename, ...)
does not retain Unicode characters in the name.
I think that is SharePoint doing it on the back end, we don't do any character substitutions that would impact this.
So, how to rename using this library?
The web interface renames using a POST to .../GetList(...)/Items(...) with body {"__metadata":{"type":"SP.Data.Shared_x0020_DocumentsItem"},"FileLeafRef":"Test \uff02 \ufe61 \uff0f \ufe55 \ufe64 \ufe65 \ufe56 \uff3c \uffe8.pdf"}
You can use the getItem() method of file followed by the update method on the returned item instance and pass in the properties you want to update:
{ FileLeafRef:"Test \uff02 \ufe61 \uff0f \ufe55 \ufe64 \ufe65 \ufe56 \uff3c \uffe8.pdf"}
Docs here on files and here on items.
Note that when I upload a file via the web interface, it retains its special characters. This is how it uploads ﹕ ﹤ ﹥ ﹖ \ │.pdf to SOME/WHERE in shared docs:
https://x.sharepoint.com/sites/APP/_api/web/GetFolderByServerRelativePath(DecodedUrl=@a1)/Files@a1: '/sites/APP/Shared Documents/SOME/WHERE'$filter: Name eq '﹕ ﹤ ﹥ ﹖ \ │.pdf'{"d":{"results":[]}}' in path and filename are handledhttps://x.sharepoint.com/sites/APP/_api/web/GetFolderByServerRelativePath(DecodedUrl=@a1)/Files/AddStubUsingPath(DecodedUrl=@a2)/StartUpload(uploadId=@a3)@a1: '/sites/APP/Shared Documents/SOME/WHERE'@a2: '﹕ ﹤ ﹥ ﹖ \ │.pdf'@a3: guid'47b779d2-4113-42e3-8ebc-9ebbfb658d53'{"d":{"StartUpload":"0"}}https://x.sharepoint.com/sites/APP/_api/web/GetFileByServerRelativePath(DecodedUrl=@a1)/FinishUpload(uploadId=@a2,fileOffset=@a3)@a1: '/sites/APP/Shared Documents/SOME/WHERE/﹕ ﹤ ﹥ ﹖ \ │.pdf'@a2: guid'47b779d2-4113-42e3-8ebc-9ebbfb658d53'@a3: 0This results in the file being uploaded with the correct name. So it seems to me that pnpjs should do the same?
@wmertens, Hm... that is what I just tried:

Can it be in how you replace the characters, the incoming string?
Oh so it's working for you? Hmmm. I'll do some further testing.
Yes, it works for me. It's likely that the string is converted in the middle before being passed to PnPjs in your case.
@wmertens, did you manage to overcome the issue? I almost convinced it is not on the library side.
Well I've been sidetracked, but until I get greater clarity in what's going on I'll close this. I'll reopen if it turns out to be an issue here after all.
Thanks for your assistance!