Siebel eScript Language Reference > Methods Reference > String Methods >

Get Unicode Character From String Method


The Get Unicode Character From String method returns the Unicode value of the character that resides at a specific position in a string. It returns a 16-bit integer between 0 and 65535. The value of the position argument identifies this position. If no character exists at this position, then it returns the following value:

NaN

This method uses the same arguments as the Get Regular Expression From String method. For more information, see Table 37. For more information, see the following topics:

Format

stringVar.charCodeAt(position)

Usage

To get the first character in a string, you use position 0. For example:

var string1 = "a string";
string1.charCodeAt(0);

To get the last character in a string, you use length minus 1. For example:

string1.charCodeAt(string1.length - 1);

If the value in the position argument is not between 0 and the value of stringVar.length minus 1, then the Get Unicode Character From String method returns an empty string.

Example

The following eScript code configures Siebel CRM to allow the user to only enter characters that are part of the Latin character set. These characters must possess a Unicode value of less than 128. The user enters these characters in the First Name field. You add this code to the Contact business component. The Get Unicode Character From String method evaluates the Unicode value of each character that the user enters in the field that the FieldValue argument specifies:

function BusComp_PreSetFieldValue (FieldName, FieldValue)
{
// prevent non latin characters in First Name field
if (FieldName == "First Name")
{
for (var i=0;i<FieldValue.length;i++)
{
var co = FieldValue.charCodeAt(i);
if (co > 127)
{
TheApplication().RaiseErrorText("Only characters from latin character set are allowed!");
}
}
}

return (ContinueOperation);
}

Siebel eScript Language Reference Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices.