Skip to main content
johnk74519883
Participating Frequently
December 15, 2018
Answered

Accented characters in variables

  • December 15, 2018
  • 1 reply
  • 1997 views

I'm doing a Spanish language form that displays a list of countries in a drop-down:

Seleccione el País

Colombia

Costa Rica

México

Panamá

Perú

The country name is is used to display different options. This worked as expected when the list of country names was in the dropdown validation box. But then I had to move the validation to a document-level script and now the validation doesn't work on any variable that has an accent in it. (Only Colombia and Costa Rica work as expected). So I added the following to the dropdown validation to try passing unaccented values to the document-level script:

var dropdown = event.value;

if (dropdown == "Seleccione el País"){

var resetDropdown = "Seleccione el Pais";

}else if (dropdown == "Colombia"){

var resetDropdown = "Colombia";

}else if (dropdown == "Costa Rica"){

var resetDropdown = "Costa Rica";

}else if (dropdown == "Panamá"){

var resetDropdown = "Panama";

}else if (dropdown == "Perú"){

var resetDropdown = "Peru";

}else{

var resetDropdown = "Mexico";

}

SetCountry(resetDropdown);

But the accents seem invisible to Acrobat Javascript. Accented dropdown names are not set as unaccented variable values, so Mexico becomes the variable value for the accented name.

In HTML JavaScript, I can set the value and the display text independently, but I can't see any way of doing that in Acrobat. Thanks for any ideas or hints.

This topic has been closed for replies.
Correct answer try67

Go back to your code in Notepad++ and click on Encoding - Convert to ANSI.

Then copy the code back to the field and it will work just fine...

1 reply

Thom Parker
Community Expert
Community Expert
December 15, 2018

I think your issue is in how the names are being moved about. The Accented characters are part of the extended ASCII set, which is called ANSI.

Acrobat JavaScript is quite literally no different than HTML JavaScript, and both handle these characters just fine, so your issue is not with JavaScript. I just tried it and I can set the names manually through the dropdown properties dialog, or with JavaScript and the accents both display and work in a validation script.

But there are two different ways in which these could be getting screwed up, outside of scripting.  The most common issue with non-standard ASCII characters is that they are not properly supported in some editing tools. If you copied and pasted from such a tool the accented ANSI characters might have been substituted with ASCII equivalents.  The second issue is that many word processing tools use UNICODE versions of these characters rather than the ANSI codes. So if you copied and pasted from a word processing tool the accented character might have been replaced. In such a case the JavaScript comparison might fail because the Unicode character code would not match the ANSI character code.

Can you post a demo form that just contains the form fields and code that have this problem. I'd be happy to look it over.

Yuu can find more information on programming dropdowns in Acrobat and PDF here:

https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm

https://acrobatusers.com/tutorials/list_and_combo_in_lc

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
johnk74519883
Participating Frequently
December 15, 2018

Thanks for your speedy reply. I'm a programmer and am using Notepad++ for code editing in Windows.

Here's a link to the version using the validation script attached to the dropdown: https://1drv.ms/b/s!AuMdOB79OSNji3Wb-T_-fjH3QVyE

Here's the version where the dropdown is passing the country name to the document script and failing: Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.

If you view these files in a browser, all layers will be visible. I'm developing this in Acrobat X, but the users are on Reader DC.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 15, 2018

Go back to your code in Notepad++ and click on Encoding - Convert to ANSI.

Then copy the code back to the field and it will work just fine...