Titanium JIRA Archive
Appcelerator Community (AC)

[AC-4640] openURL UTF8 GET parameters problem

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-12-01T14:34:04.000+0000
Affected Version/sAppcelerator Studio 4.5.0
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsios
ReporterMorten Hopstad
AssigneeShak Hossain
Created2016-11-24T09:37:27.000+0000
Updated2016-12-01T14:34:04.000+0000

Description

Hello. On Android build made on Windows computer this is working fine. On my MAC computer making the iOS build however I can not get this to work. I open an URL like this :
var test = 'æøå';
var test2 = 'MoreÆØÅ';
var url = 'https://somesite.com/?getParam1=' +test+ '&getParam2=' + test2;
openURL(url);
--- Result is a messed up string . I have also tried using Ti.Network.encodeURIComponent('øæå'); with the same result.

Comments

  1. Sharif AbuDarda 2016-11-24

    Hello, What Titanium SDK are you using? Can you send a full sample code? Use the latest studio and SDK version. Thanks.
  2. Morten Hopstad 2016-11-25

    Hello. I'm using the latest version of everything. (SDK is V6.0.0.GA) My code is used for opening a direct chat into a company and includes some semi-private keys etc. Therfor it will be difficult for me to show this exact code online for the public to see. Im doing the same thing on both the Android version and the iOS version. As mentioned, the Android version built on the Windows computer works fine but the iOS built on MAC shows the following:
       // Make URL
       var url = 'url.somecompany.com';
       
       // Some variables
       var customerKey = "123456";
       var something = 'æøå';
       
       // Add parameters to URL
       url = url + 
       '?customerKey=' + customerKey +
       '&something=' + something;
       
       // Open browser
       Titanium.Platform.openURL(url);
       
       // This opens a site that shows some of the given variables back to the user. "something" in this case.
       // It shows like this %C3%A6%C3%B8%C3%A5
       // Same result with and without Ti.Network.encodeURIComponent();
       
  3. Hans Knöchel 2016-11-27

    Two things here: - The Ti.Network.encodeURIComponent works correctly, it encodes it utf-8 conform - You should try to avoid (un-encoded) special characters in requests, and if you do, your server would need to know how to deal with the encoded URI-string. This does not like an Titanium issue to me. Please try [this link](http://httpbin.org/get?param=More%C3%86%C3%98%C3%85) which will encode it the same way as the method does. We can test it with a native project as well, but it will most likely be the same.
  4. Morten Hopstad 2016-11-28

    Hello and thank you for respons. My first thought was also that this was how the server is handling these encoded strings. But then I can see it's working in 2 of 3 cases. That was what made question Titanium and made a ticket. Android Build : Works fine. The string is decoded on the server and shows properly. Website (Javascript) : Works fine. Using URI-encoding (encodeURI()) iOS : Trouble. Cant be decoded.
  5. Sharif AbuDarda 2016-11-30

    Hello, I tried testing in simulator with your sample code. I wasn't able to reproduce the issue in iOS, The URL is same as it should be.
       https://somesite.com/?getParam1=æøå&getParam2=MoreÆØÅ
       
    See my [screenshot](http://i64.tinypic.com/11vlely.jpg) of the browser trying to open the url in iOS simulator.
       Operating System
         Name                        = Mac OS X
         Version                     = 10.11.6
         Architecture                = 64bit
         # CPUs                      = 4
         Memory                      = 8589934592
       
       Node.js
         Node.js Version             = 4.2.2
         npm Version                 = 2.14.7
       
       Titanium CLI
         CLI Version                 = 5.0.10
       
       Titanium SDK
         SDK Version                 = 6.0.0.GA
       

JSON Source