Name

String.charCodeAt( ) Method — retrieve the code point of the character at a specific position in a string

Availability

Flash 5

Synopsis

string.charCodeAt(index)

Arguments

index

The integer position of a character in string, which should be in the range 0 (the first character) to string .length-1 (the last character).

Returns

An integer representing the Latin 1 or Shift-JIS code point, as shown in Appendix B, of the character in the position index within string.

Example

var msg = "A is the first letter of the Latin alphabet.";
trace(msg.charCodeAt(0));  // Displays: 65 (the code for the "A" character)
trace(msg.charCodeAt(1));  // Displays: 32 (the code for the space character)

See Also

String.charAt( ), String.fromCharCode( ); Appendix B, Section 4.6.9.2 in Chapter 4

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.