Archive: modifying strings


modifying strings
I have a normal windows path string like "C:\windows\my programs" and I need it to be converted to "C:/windows/my%20programs".

At the beginning I thought I only needed to change backlashes to lashes, but now I realise special characters need to be changed aswell.

Does anybody know a good trick?

The only way I know how to proceed is a single character check to every special character, which would result in a big big code.


If you don't mind having a dependency on Internet Explorer 3.0 and above, you can use InternetCanonicalizeUrl. It's an API function provided by wininet.dll.


For example:

StrCpy $0 "http://nsis.sf.net/some spaces/path\with\back slashes"
System::Call "wininet::InternetCanonicalizeUrl(t r0, t .r0, \
*i ${NSIS_MAX_STRLEN}, i 0)"
DetailPrint $0

perfect, exactly what I needed :D

I hope my users don't have any problem with ie3...