[Gambas-user] string conversion

Matti math.eber at ...221...
Thu Nov 12 21:14:57 CET 2009


Well, after some thoughts, I can answer myself.

I tried this example:

  sFilename = "/home/username/Meine Bilder/öffentliche Fotos übertragen/015 das Schönste.jpg"
  i = 1
  WHILE i < Len(sFilename)
    sChar = Mid$(sFilename, i, 1)
    IF Asc(sChar) > 122 THEN
      sFilename = Left$(sFilename, i - 1) & "%" & Hex$(Asc(sChar)) & Right$(sFilename, Len(sFilename) - i)
    ELSE IF sChar = " " THEN
      sFilename = Replace$(sFilename, " ", "%20")
    ENDIF
    i = i + 1
  WEND
  sOut = "file://" & sFilename
  PRINT sOut

and it seems to work ok and reasonably fast.
But if you have better ideas, you're welcome!



Matti schrieb:
> Hi,
> 
> I'm looking for a string conversion function for URIs.
> It should work like CGI.Encode, but
> - don't transform slashes "/"
> - transform spaces " " not to "+" but to "%20".
> 
> Couldn't find anything in Gambas. Maybe a shell command?
> 
> Thanks
> Matti




More information about the User mailing list