Decode URL paramters and Umlauts

Good afternoon

I’m trying to handle the URL scheme apple event which launches my barcoder app fine…

Only problem is that it won’t display then the text correctly with Umlauts…

For example this link parameter:

addr=B%C3%BCechschew%C3%A4g+5

is turned into during link opening:

addr=Büechschewäg+5

Which is fine…but Xojo renders it then in a TextField as:

B��echschew��g+5

Setting the TextFields manually like:

ctrl.Text = “Mäny Ümläüts”

Works fine though…so is there some UTF8 conversion function missing here?
Text.DefineEncoding(Encodings.UTF8) and DecodeURLComponent don’t work…

thanks in advance
richard

If the text isn’t utf8 then test with IsoLatin1.

1 Like

It is actually the ASCII representation of UTF8:

%C3BC is the encoding in ASCII for ü

Seems the only way to search/replace for each individual UTF8 representation and replace it as I don’t see any encoding which matches this…

In Swift this is done transparently…

In Xojo encodings are handled transparently, too. Please show us your complete code.

This code works for me

  dim s as string = "B%C3%BCechschew%C3%A4g"
  dim t as string = DecodeURLComponent(s)
  t = DefineEncoding(t, encodings.utf8)
  textfield1.text = t

I get umlauts in the text field.

Using this code:

dim p as NSAppleEventDescriptorMBS = theEvent.paramDescriptorForKeyword("----")

Dim params() as String
Dim s() as String
Dim line as String

line = DecodeURLComponent(p.stringValue)
params = line.Split("?")

If params.count = 2 Then
  Dim param() as String = params(1).Split("&")
  For Each par as String in param
    s = par.Split("=")
    Parameters.Add(s(0))
    Values.Add(s(1))
  Next
End If

If Parameters.count > 0 Then
  For i as Integer = 0 to Parameters.LastIndex
    Dim ctrl as DesktopTextField
    ctrl = Window1.GetControl(Parameters(i))
    If ctrl <> nil Then
      ctrl.Text = Values(i)
    End If
  Next
End If

I get with using PHP urlencode for GET parameters:

B��echschew��g+5

Or without using urlencode in PHP:

B��echschew��g 5

Try

ctrl.Text = DefineEncoding(Values(i), encodings.utf8)
1 Like

Ah that works…but only without doing urlencode in PHP and then without DecodeURLComponent :slight_smile:

What are you trying to do? I never had to use DecodeURLComponent when dealing with NSAppleEventDescriptorMBS.