DecodeURLComponent and Text (not string)

Is there an equivalent to DecodeURLComponent() that works with Text, as opposed to a String? Or do I have to convert my Text to a String in order to use it?


From my M_Text module:

Protected Function FromURLEncoded(src As Text, encoding As Xojo.Core.TextEncoding = Nil) as Text
  // Emulates DecodeURLComponent from classic framework
  // If encoding is not specified, assumed to be UTF-8
  if src.Empty then
    return ""
  end if
  if encoding is nil then
    encoding = Xojo.Core.TextEncoding.UTF8
  end if
  dim srcMB as Xojo.Core.MemoryBlock = Xojo.Core.TextEncoding.ASCII.ConvertTextToData( src )
  dim destMB as new Xojo.Core.MutableMemoryBlock( src.Length )
  dim mbIndex as integer
  dim charIndex as integer
  dim lastCharIndex as integer = srcMB.Size - 1
  while charIndex <= lastCharIndex
    dim code as integer = srcMB.Data.Byte( charIndex )
    if code = 37 then // "%"
      code = Integer.FromHex( src.Mid( charIndex + 1, 2 ) )
      charIndex = charIndex + 3
      charIndex = charIndex + 1
    end if
    destMB.Data.Byte( mbIndex ) = code
    mbIndex = mbIndex + 1
  dim mb as Xojo.Core.MemoryBlock = destMB.Left( mbIndex )
  dim r as text = encoding.ConvertDataToText( mb )
  return r
End Function

Wow - I just grabbed your M_Text module, and it feels like Christmas. Thanks for this function and all the others!

Just did the same myself… What Andrew said +1