Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Encode URLs to ISO-8859..?

New Here ,
Feb 11, 2016 Feb 11, 2016

Hi..


I am trying to open a Google Maps URL from 4 filled variables via a form in Acrobat.

I am using this Javascript code:

var Adresse = getField("Adresse").value;

var Nr = getField("Nr").value;

var Postnr = getField("Postnr").value;

var By = getField("By").value;

var myURL = "http://www.google.dk/maps/place/"+Adresse+"+"+Nr+"+"+Postnr+"+"+By;

app.launchURL(myURL, true);

But when having ”æ”, ”ø” and ”å” in the variables, the output URL is not correct. This is my output:

https://www.google.dk/maps/place/H%E6vlingeb%E5nken+17+4681+Herf%F8lge

when typing these variables:

Skærmbillede 2016-02-11 kl. 09.01.08.png

So I need somehow to encode the URL to ISO-8859...or other encoding? so the characters "æ", "ø" and "å" are used correctly...

Is that possible?

TOPICS
Acrobat SDK and JavaScript
721
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 11, 2016 Feb 11, 2016

Also, you don't need a function for this, just add this line before the launchURL command:

myURL = encodeURI(myURL);

Translate
Community Expert ,
Feb 11, 2016 Feb 11, 2016

Try JS's global encodeURI method.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 11, 2016 Feb 11, 2016

Hi try67

Thanks for your reply. I am not a skilled coder, just a graphic designer trying my best to make things work

So I am not sure how to use that method correctly...

From what I can read about the method on that page, I have inserted it like this, but I get a SyntaxError from Acrobat...

Skærmbillede 2016-02-11 kl. 10.37.40.png

Any help writing the exact code is VERY appreciated

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 11, 2016 Feb 11, 2016

Remove all of the "replace" commands you added. They should not be necessary after the encodeURI command.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 11, 2016 Feb 11, 2016

Also, you don't need a function for this, just add this line before the launchURL command:

myURL = encodeURI(myURL);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 11, 2016 Feb 11, 2016
LATEST

YOU ARE A STAR..!!!!!

Thank you so much..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines