When I use ShowURL(“1010%20Cit%20Administrative%20de%20l’Etat%20Bruxelles-Capitale”) in an iOS app, the URL will not open and no error is shown.
When I use this declares, I get “Can not open URL”
Declare Function NSClassFromString Lib "Foundation" (className As CFStringRef) As Ptr
Declare Function sharedApplication Lib "Foundation" Selector "sharedApplication" _
(UIApplicationClass As Ptr) As Ptr
Declare Function URLWithString Lib "UIKit" Selector "URLWithString:" _
(NSURLClass As Ptr, url As CFStringRef) As Ptr
Declare Function openURL Lib "UIKit" Selector "openURL:" (UIApplication As Ptr, NSURL As Ptr) As Boolean
Dim UIApplicationPtr As Ptr = sharedApplication(NSClassFromString("UIApplication"))
Dim NSURLPtr As Ptr = URLWithString(NSClassFromString("NSURL"), "1010%20Cit%20Administrative%20de%20l'Etat%20Bruxelles-Capitale")
If openURL(UIApplicationPtr, NSURLPtr) Then
// Success
Else
// Error
MsgBox "Can not open URL: " + URL
End
A basic encodeURLComponent is not that difficult to do : after all, a series of search replace suffices to encode the 4 vowels with grave, acute, circumflex and dieresis, which is total 32 with upper and lowercase, then lower and uppercase.
That should suffice for French, German (add ), Italian. Spanish (add and ).
Public Function EncodeURLComponent(value as text) as text
Declare Function CFURLCreateStringByAddingPercentEscapes lib "Foundation" (allocator as Ptr, origString as CFStringRef , charactersToLeaveUnescaped as CFStringRef , legalURLCharactersToBeEscaped as cfStringRef,encoding as uint32) as CFStringRef
return CFURLCreateStringByAddingPercentEscapes(nil, value, nil, nil, &h08000100)
End Function
I didn’t write it but I don’t have a record of who did so I apologise for not crediting anyone.