These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

javascript encoding thr strings

St Peterburger
Registered: Apr 27 2009
Posts: 15

Problem with non-ASCII characters in Javascript side?

This is my ActionScript code in Flex:

<?xml version="1.0" encoding="utf-8"?>

and here is the JavaScript counterpart in PDF:

//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------

//
//Testing
//
/*********** belongs to: Document-Level:Testing ***********/
function PdfFunction(cMsg) {
app.alert(cMsg,3);
};

//
//

//
//Page1:Page Open:Action1
//
/*********** belongs to: Page-Actions:Page1:Page Open:Action1 ***********/
this.getAnnotsRichMedia(this.pageNum)[0].activated = true;

//
//

Button label seems to be OK, but alert box shows funny characters...
anybody knows how to fix this? How I told encoding in JavaScript?

Freelancer
Registered: May 26 2009
Posts: 71
Hello StP,
JavaScript native encoding is as utf-16...
also I can't get this to work :-(

seems that there is a limitation to send
'special' character strings to pdf.
Other users (Thomp, gkaiseril, joshcorey), is it so?

Regards,

Freelancer

According to most IT HelpDesk people, the most common reason for user error (regardless of Operating System) is ID 10T.

Freelancer
Registered: May 26 2009
Posts: 71
Problem solved, quick and dirty... but one can't always win.
I wonder if this is permanent restriction in this environment...
Click OK to terminate.

FlexBuilder:

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:Script><![CDATA[import flash.external.ExternalInterface;public function Send2Pdf():void{ExternalInterface.call('PdfFunction',("ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"));};]]></mx:Script><mx:Button label="Paina!" click="Send2Pdf()" top="10" left="10"/></mx:Application>

And Acrobat:

//<Document-Level>//<ACRO_source>Testing</ACRO_source>//<ACRO_script>/*********** belongs to: Document-Level:Testing ***********/ function repAl(strText,strTar,strRep){var intIndexOfMatch = strText.indexOf(strTar);while (intIndexOfMatch != -1){strText = strText.replace(strTar,strRep)intIndexOfMatch = strText.indexOf(strTar);}return(strText);} function PdfFunction(cMsg) { var sRep = ['À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ'];var sTar = ['À','à ','Â','Ã','Ä','Ã…','Æ','Ç','È','É','Ê','Ë','ÃŒ','à ','ÃŽ','à ','à ','Ñ','Ã’','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ãœ','à ','Þ','ß','à ','á','â','ã','ä','Ã¥','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ']; for (i=0;i<=63;i++){cMsg = repAl(cMsg,sTar[i],sRep[i]);};app.alert(cMsg,3);}; //</ACRO_script>//</Document-Level>

Freelancer

According to most IT HelpDesk people, the most common reason for user error (regardless of Operating System) is ID 10T.