How to Use fromCharCode and charCodeAt in javascript flash

Source: Internet
Author: User

FromCharCode Method
Returns a string from some Unicode character values.
String. fromCharCode ([code1 [, code2 [,... [, codeN])
Parameters
String
Required. Is a String object.
Code1,..., codeN
Optional. Is the sequence of Unicode character values to be converted to strings. If no parameter is provided, the result is a null string.
Description
You do not need to create a String object before calling fromCharCode.
In the following example, test contains the string "plain ":
Var test = String. fromCharCode (112,108, 97,105,110 );
Requirements
Version 3
See
CharCodeAt method | String object Method
CharCodeAt Method
Returns an integer representing the Unicode encoding of the characters at the specified position.
StrObj. charCodeAt (index)
Parameters
StrObj
Required. Any String object or text.
Index
Required. Number that counts the characters to be processed from scratch. The valid value is a number ranging from 0 to 1 minus the string length.

Description
The first character in a string is 0, the second character is 1, and so on.

If the specified position does not contain any characters, NaN is returned.

Example
The following example illustrates the usage of the charCodeAt method.

Function charCodeAtTest (n ){
Var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // initialize the variable.
Var n; // declare the variable.
N = str. charCodeAt (n-1); // obtain the Unicode value of the character at the position n.
Return (n); // return this value.
}


Flash
String. fromCharCode


Availability
Flash Player 5.
Usage
String. fromCharCode (c1, c2,... cN)
Parameters
C1, c2... cN indicates the decimal integer of the ascii value.
Return

None.

Description

Returns a string consisting of Characters in the parameter ASCII value.

Example


In this example, a "@" character is inserted in the email address using the fromCharCode method.

Address = "admin" + String. fromCharCode (64) + "jb51.net ";
Trace (address );
// Output: admin@jb51.net

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.