0.1.0 • Published 1 month ago

@stdlib/string-to-well-formed v0.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 month ago

str2wellformed

NPM version Build Status Coverage Status

Create a new well-formed string.

Installation

npm install @stdlib/string-to-well-formed

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'

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.