@stdlib/string-to-well-formed
v0.1.1
Published
Convert a string to a well formed string.
Downloads
11
Readme
str2wellformed
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
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.