SecureString.convertEncoding(options)

Method Description

Converts the content of a https.SecureString between two encodings.

Returns

The converted https.SecureString (not a new SecureString).

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/https Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.fromEncoding

string

required

The encoding to be used to decode the current content of the SecureString.

Use values from https.Encoding.

options.toEncoding

string

required

The encoding to store the content as.

Use values from https.Encoding.

Errors

Error Code

Thrown If

FAILED_TO_CONVERT_BINARY_DATA_TO_UTF_8

The content of the SecureString is binary data and it does not represent a valid UTF-8–encoded string.

FAILED_TO_DECODE_STRING_ENCODED_BINARY_DATA_USING_1_ENCODING

The content of the SecureString is not a valid encoded string according to the options.fromEncoding parameter value.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/https Module Script Samples.

          // Add additional code 
...
var secureString1 = https.createSecureString({
    input: "myString1"
});
log.debug("secureString1 before convertEncoding", secureString1);

secureString1.convertEncoding({
    fromEncoding: https.Encoding.UTF_8,
    toEncoding: https.Encoding.HEX
});
log.debug("secureString1 after convertEncoding", secureString1);
...
// Add additional code 

        

Related Topics

General Notices