str2wellformed

Create a new well-formed string.

Usage

var str2wellformed = require( '@stdlib/string/to-well-formed' );

str2wellformed( str )

Creates a new well-formed string by replacing all lone surrogates with the replacement character \uFFFD.

var result = str2wellformed( '' );
// returns ''

result = str2wellformed( '\uDBFF' );
// returns '�'

result = str2wellformed( '\uDBFFFF\uDBFF' );
// returns '�FF�'

result = str2wellformed( '-5' );
// returns '-5'

Examples

var str2wellformed = require( '@stdlib/string/to-well-formed' );

var result = str2wellformed( '' );
// returns ''

result = str2wellformed( '\uDBFF' );
// returns '�'

result = str2wellformed( '\uDBFF\uDBFF' );
// returns '��'

result = str2wellformed( '5\uDBFF' );
// returns '5�'

result = str2wellformed( '-5' );
// returns '-5'
Did you find this page helpful?