ExtendScript handling special characters

Hello

I'm working on my first script for After Effects. I've never worked with JavaScript so please bare with me if the answer to my question is very simple.

I am simply read a .txt file and parses strings in variables. I then take these variables and using the strings to populate the text layers in After Effects. Everything works perfectly and more that he will not perform "special characters" in the Spanish language. How JavaScript to allow these characters to be filled in text layers?

Here is my code:

MAIN FUNCTION

var newFile = File.openDialog ("file read.");

If (newFile! = null) {}

var a = readDocument(newFile,_1).contentAry;

replaceText (a);

}

Checks if the document exists-> If Yes, creates new table and populates file

function readDocument (inputDoc, linesToSkip) {}

var curDoc = new queue (inputDoc);

{if (curDoc.Exists)}

var contentAry = new Array();

curDoc.open ("r");

fills up to the end of the txt file

{while(!curDoc.EOF)}

contentAry [contentAry.length] = curDoc.readln ();

}

curDoc.close ();

}

Replaces the normal table space characters

contentAry.splice (0, linesToSkip);

var contentList = contentAry.join("_gap_").toString () replace (new RegExp ("_gap_", "g"), '\r');

contentAry = contentAry;

return {}

'contentAry': contentAry,

"contentList": contentList

}

}

Function to replace text in layer

function replaceText (content) {}

try {}

variables for specific layers that are targeted

var layerOneA = app.project.item (3) .layer (1);

var layerTwoA = app.project.item (3) .layer (2);

var layerThreeA = app.project.item (3) .layer (3);

var layerOneB = app.project.item (4) .layer (1);

var layerTwoB = app.project.item (4) .layer (2);

check that the parameter passed through to the function is an array

If {(contents instanceof Array)

var curLine, lineOne, lineTwo, lineThree, lineFour, pl;

var aryLength = content.length;

runs the table & analysis of its data to variables

for (var i = 0; i < aryLength; i ++) {}

curLine = happy [i];

PL = parse (curLine);

lineOne = pl.title;

lineTwo = pl.msg;

lineThree = pl.tune;

lineFour = pl.name;

Another used for loop so the function works on the main compositions (all nested these comps)

for (var x = 0; x < 2; x ++) {}

if(x == 0) {}

layerOneA.sourceText.setValue (lineOne);

layerTwoA.sourceText.setValue (lineTwo);

layerThreeA.sourceText.setValue (lineThree);

} else {}

layerOneB.sourceText.setValue (lineOne);

layerTwoB.sourceText.setValue (lineThree);

}

}

docName.name.setValue (lineFour);

Alert (docname. (Name)

}

}

'\r',} catch (err) {alert (err.line.toString () + err.toString ())};

}

Split strings in the table into separate objects

function parse (myText) {}

{while (!) MyText.EOF)}

var t = myText.split ("\t");

return {}

'title': t [0],

'msg': t [2],

'tune': t [3].

'name': t [4]

}

}

}

Thank you very much for your help!

The file object has a 'encoding' property, see the Guide to the JavaScript section on "Unicode i/o tools.
Make sure you read the txt file in the encoding it is written. Better to use an encoding like utf8 that supports way more special than ascii symbols, for example.

Tags: After Effects

Similar Questions

  • How to handle special characters in the Apex

    Hello

    In my application, I have two regions - region report (interactive report) and other is region HTML with text elements two - Empno and name

    My report has two columns Empno (varchar2) and Ename (varchar2).

    When I click on the link change in the column of the report, the empno should be a read-only value EMPNO and ename is a text with the value of the ENAME field.

    When I run my application, I have encountered the following problems:
    1. If my empno has special characters such as "#", the characters after that is not posting
    2. If my empno has special characters such as "," characters after the decimal point is considered to be a value of next texitem

    Here is my authentication information,

    CTSAN_ORACLE_DB workspace
    Username [email protected]
    Password lakshmi321
    URL: http://apex.oracle.com/pls/apex/f?p=9444:19:4292839314890159:


    Please, I beg you. suggest me how to fix these problems.

    Thank you
    David...

    Published by: David on August 13, 2010 03:05

    Do not pass the data values in the URL. If it is possible to escape values to make URL - and APEX parameter-safe, it is much better to avoid the problem completely.

    Create a primary key of the substitution on the table which is an immutable discreet digital identifier and use it only as a URL parameter. In pages/target areas, use this value of PK to extract the data from the table.

  • JSON format - Date and special characters

    Hi all

    I had a JSON server in which, I have a few text values and date.

    1. How can I convert special characters to normal String.e.g. Comma etc. ?
    2. How can I convert long date, a string in the format e.g. "1345670466960-0400"?

    I really appreciate any help above.

    Solved... Where the above closure. For others, I will post the solution.

    Special characters-

    QByteArray buffer(bufSize, 0);
    int read = reply->read(buffer.data(), available);
    //response = QString(buffer); -- Wrong way to convert the bytes.
    response = QString::fromUtf8(buffer); // right way, so special character handled itself.
    

    Day fromatting - for example "/ Date (1345670466960-0400).

    QString getStringDate(QString k){
        QDateTime date = QDateTime::fromTime_t(getDate(k));
        QString strDate = date.toString("MM/dd/yyyy HH:mm:ss");
        return strDate;
    }
    long getDate(QString k) {
        long rc = 0;
        QString v = k;
        if (v.length() > 0 ) {
            int b = v.indexOf("/Date(");
            if (b >= 0) {
                b += 6;
                int e = v.indexOf(')', b);
                if (e > b) {
                    QString s = v.mid(b, e);
                    int sign = 1;
                    if (s.indexOf('-') > 0 || s.indexOf('+') > 0) {
                        sign = s.indexOf('-') > 0 ? -1 : 1;
                        e = sign < 0 ? s.indexOf('-') : s.indexOf('+');
                        s = s.mid(0, e);
                    }
                    bool *ok = false;
                    s = s.mid(0, s.length() - 3); //trimming it for seconds only....
                    rc = s.toLong(ok, 0);
                }
            }
        }
        return rc;
    }
    
  • xmlserialize with special characters

    Hello

    I am looking for a way to preserve special characters when using xmlserialize:

    When I run this query:

    Select xmlserialize (content xmltype('<Owner>Grand''co</Owner>').extract('/*') dash)

    Double;

    I get this result:

    < owner > big& apos; Co < / owner >

    I like to keep the "'" instead of having the "& apos;

    Does anyone have a solution?

    Thank you

    Martin

    Post edited by: Martin L.

    I don't have a problem but the xml code is downloaded from a Government website, and I don't know if they have properly managed these reserved characters. I don't know if they will save in their database of escape characters "" or they it will convert the reserved character.

    I don't think you need to worry about this.

    An XML parser must properly handle these characters and the corresponding predefined entity references.

  • The menu label Muse with special characters when exporting html site, do not work

    I create a web site with a menu navigation Muse. In the menu (labels), I have some special characters (Portuguese characters) as a and i (official, noticias) c. When I export to html format in a folder this menu buttons don't work - html link - http://agml.pt/agmlteste/ . But when I save the temporary link Business Catalyst site - http://agml.businesscatalyst.com/ keys work well. Thanks for the help!

    The issue here is your host is not configured to serve the page with special characters names, but BC does not handle them correctly.

    Right-click on your pages and choose "Page Properties".  Go to the third tab, 'options', and clear the check box to use filename with the same name as the Page name.

    Use a file name that does not contain these special characters and it should work fine.

    See you soon,.

    Justin price

    Community Manager

  • How to insert special characters

    Hey,.

    I can't understand how to insert special characters in a paragraph (the "Indent to Here" in this case).

    I tried text_frame.paragraphs [0] .silence += SpecialCharacters.INDENT_HERE_TAB;  but all I get is "1397319796" instead of the actual character.

    How to insert special characters instead of these numbers?

    Zoffix222 wrote:

    People who visit, but nobody don't know it?

    What, you mean that in the 5 minutes that you posted it responded to nobody? Shocking indeed.

    You already learned by yourself, 'content' is the wrong type of object stuff "SpecialCharacters' in. 'content' is the content of the text, translated in a simple string of Javascript. Only when you change a single 'character', you can use "SpecialCharacters", because at that time there Extendscript will see that you do not want to change the string "full"?

  • Special characters in the wrong Exif IFD0 (ImageDescription) export

    Someone at - it having problems with special characters such as a, o, u, e, to?

    I have a description of the image written to the IPTC section which Lightroom stores in EXIF too. Most GUI display the correct characters, but if you look at the Exif IFD0 part these characters are changed.

    In the example, you see that the 'u' is missing in 'Innsbrücke' below.

    Exif_IFD0.png

    You can see the original image here:

    http://www.Hirst.ch/content/09%20Ferien/2010%20-%20Adlerweg%20-%20Teil%202/2010%20-%20Adle rweg%20II%20-%20017.jpg

    The following link shows how the extracted tag of EXIF (ImageDescription) gets poster:

    http://www.Hirst.ch/#/content/09%20Ferien/2010%20-%20Adlerweg%20-%20Teil%202/2010%20-%20Ad lerweg%20II%20-%20017.jpg

    Just to show that there is nothing wrong with the GUI, check after the example (not exported Image with LR3) which work perfectly well:

    http://www.Hirst.ch/content/09%20Ferien/2008%20-%20Jordanien/2008%20-%20Jordanien%20-%2002 6. jpg

    http://www.Hirst.ch/#/content/09%20Ferien/2008%20-%20Jordanien/2008%20-%20Jordanien%20-%20 026 jpg

    Exif_IFD0_2.png

    Any help on getting these correct special characters in EXIF would be very much appreciated.

    Thank you

    It always resembles a UTF-8 conversion tank Latin problem.

    Honestly, most former EXIF fields are not going to be able to handle characters-international, but what is stored there, and what is displayed in the interfaces will be highly contextual.

    The plugin I mentioned can be used to standardize the metadata in order to minimize this problem.

  • Replace special characters in the FDF

    Hello

    I've looked everywhere and can't find the answer to this simple problem.  I can handle javascript in an HTML environment using free scripts, but it is not so easy in a PDF form.  I use Adobe Acrobat 9 Pro and I have a form that once completed and submitted, generates and sends a FDF file.  I use a script on the server side, called FormGenie do this and the script hate parentheses and some other characters, they break the FDF file.  Everything I want to do is set up a document level Javascript that find and replace all instances of these special characters with something license as a hyphen - or just a space.

    I tried:

    function clearText() {}
    document. FormName.FieldName.Value = filterNum (document. FormName.FieldName.value)

    function filterNum (str) {}
    re = /\$|#|~|\%|\*|\^|\(|\)|\+|\=|\[|\]|\[|\}|\{|\;|\"|\<|\>|\?| \|| \\|\!| \$/g;
    remove special characters as ' $' and ',' etc...
    return str.replace (re, "-");
    }
    }

    and

    function clearText2 (str) {}

    stringName = stringName.replace (/------$| #| ~ |------% |------* |------^ | \(|\) |--------+ |------= |------[|------] |------[{|------} |------{|------; |------"|"}]) ------< | ------> | \ ? | \|| \\|\!| \$ /g,'-');
    }

    I know that these are not good, but I have to be at least barking to the top of the tree on the right.

    Can anyone help?

    Thank you

    You create the form in Acrobat or LiveCycle Designer?

    In general, you can place a script typo in the script of the text of each filter field field hit, in the case where something replacing the user typed with something else would not cause the concern of the user. An alternative would be to be implemented a script that parses the fields just before the submission form action takes place and not to replace them.

    For example, you can use the following JavaScript typo customized for text fields created in Acrobat:

    If (! event.willCommit) {}

    Event.change = event.change.replace (/ [------$# ~ %------*------*------^ \ (\)------+=------[\]------{\};------"\<\>\?]) \ | \\\ !] /g, "-");

    }

    and it will replace these characters when the user types the data into a text field. May not include all the character you want replaced, but you should get the idea.

  • CLOB with special characters

    We have recently updated our database from a character set to UTF8. Since then, a function of database using DBMS_LOB. SUBSTR to return 4,000 characters both stopped working when the text contains special characters (accents, tilda, etc.). I know that our DBA converted all the fields of VARCHAR2. For example, he changed a field with the data type of VARCHAR2 (10) to VARCHAR2 (10 char). Is there a similar conversion to CLOB fields?

    user2486268 wrote:
    The problem may be the function itself. This is the code:

    My first thought was that I had to change v_return_answer VARCHAR2 (4000) to v_return_answer VARCHAR2 (4000 tank). I tried, but it made no difference. Here's an example of what look like parameters in the function call:
    SELECT f_get_long_answer (1307003,2,15,'L1',1)
    OF THE DOUBLE

    When there is a special character in the area of the sarquan_long_answer, he gets this Oracle error:
    ORA-6502: PL/SQL: digital or value error: character string buffer too small.

    I think that you already have the position in the right direction - your problem is that the DBMS_LOB. SUBSTR function is now trying to copy the 4,000 characters in your field of VARCHAR2.

    Many characters with your UTF8 characters will now allocate more than a single byte.

    So if you need to change the local variable to semantics (4000 tank) TANK if not changed a default of your DBA (parameter NLS_LENGTH_SEMANTICS) - but there is a limitation in Oracle that SQL can manage up to 4 000 bytes VARCHAR2 (PL/SQL can handle up to 32767 bytes in the latest versions of Oracle) - and if you try to copy the 4,000 characters in your local variable it will succeed to within the service, if the variable is defined as char 4 000, but it will fail to return the value of SQL.

    So I assume you are using this function in SQL and then fails with this error message if you try to use SQL from whenever the local variable is greater than 4 000 bytes. If your local variable is defined with the semantics of character then he must really succeed if you use from within PL/SQL, provided the variable that will receive the return of the value function is also defined to be big enough.

    Since a single character in UTF8 can allocate up to 4 bytes you can only assume back up to 1,000 characters now that SQL function, is over 4,000. Everything from 1 001 to 4 000 characters can potentially fail now in the SQL engine.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    Co-author of the book "OakTable Expert Oracle practices":
    http://www.Apress.com/Book/view/1430226684
    http://www.Amazon.com/Expert-Oracle-practices-database-administration/DP/1430226684

  • validation to check him point does not contain any special characters except ' - '.

    Hi all

    I have a question and the need to create a validation so that the item does not contain special characters (or numbers or spaces) other than salvation fen. That is to say, the element must contain only alphabets or ' - '. Tried to use the Is_Alpha function, but do not know how to handle this exception to the use of '-' in validation. So please, can someone suggest me a solution.

    Thank you
    Vignesh

    Vignesh,

    You can create Validation based on return Boolean and returns a False when the element has charecters other than 'A - Z' (charecters upper and lower) and - (hifen).

    if trim(translate(upper(:P1_ENAME), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-'
                                                      '                                                  ') is null then
       return false;    -- replacing all the alphabets and hifen with spaces... trim will leave an empty string(which is null)
    else
       return false;
    end if;
    

    Based on the following sql instructions...

    sql> select nvl(trim(translate(upper('ASDFG---'), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-',
      2                               '                           ')),'Null Value')
      3     from dual;
    
    NVL(TRIM(T
    ----------
    Null Value
    
    sql> ed
    Wrote file afiedt.buf
    
      1  select nvl(trim(translate(upper('9999Asf---'), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-',
      2                               '                           ')),'Null Value')
      3*    from dual
    sql> /
    
    NVL(
    ----
    9999
    
  • Manages the entries of the user... of special characters and things

    I was wondering but in my case that I have to accept the entry of user in preparation for sending emails. APEX text box controls manage the entry so that any special characters or oracle commands are ignored so that they become plain text? If not, is there an easy way to handle this? In my case, I'm alittle concerned by the fact that I send the e-mail using PL/SQL, so he needs to not only check HTML but PL/SQL special characters special characters and escape characters in need.

    David,

    You're safe with just using a variable binding.

    See you soon,.

    Janet Tyson

  • How to insert special characters when I hit e-mail or Facebook?

    How to insert special characters when I hit e-mail or Facebook?

    See also:

  • Web development Toolbox prevents me from using the letter upercase, special characters and all that requires the use of the SHIFT key. Help.

    whenever I press the SHIFT key, the web development Toolbox opens. I am unable to use the letter upercase, special characters and everything that requires the SHIFT key. It's really annoying me... i can't even use an exclamation mark111111

    The sounds you have a sticky key which is in the pressed state.

    Do you mean the box tools that should open via Ctrl + Shift + K or open more to the Toolbox that is displayed via Ctrl + F2?

    Try to press the keys involved several times, see the Web Developer menu for the shortcut keys.

    Have you tried to close and restart Firefox or restart the computer?

  • Where to find and install special characters in Firefox?

    Where to find and install special characters sets (French, German and Spanish) in my Firefox with Dutch language?
    TIA
    Joep

    Translation:

    TOOLS = > Options = > content = > languages = > click "Select" and then "select a language to add."

    For the character encoding:

    TOOLS = > Options = > content = > fonts and colors = > advanced (button) = > character encoding

  • How to enter special characters/symbols (i.e. the degree character) in the text boxes?

    Not a problem/w Firefox - I was wondering if there is a way to enter the special characters and characters (not on the keyboard) in the text boxes? I remember that there is a keyboard sequence that activates a context menu allowing the single character/symbol entry. Thanks in advance, Allan.

    See:

Maybe you are looking for