README.md (2622B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # Remove UTF-8 BOM 22 23 > Remove a UTF-8 [byte order mark][bom] (BOM) from the beginning of a string. 24 25 <section class="intro"> 26 27 </section> 28 29 <!-- /.intro --> 30 31 <section class="usage"> 32 33 ## Usage 34 35 ```javascript 36 var removeUTF8BOM = require( '@stdlib/string/remove-utf8-bom' ); 37 ``` 38 39 #### removeUTF8BOM( str ) 40 41 Removes a UTF-8 [byte order mark][bom] (BOM) from the beginning of a `string`. 42 43 ```javascript 44 var str = removeUTF8BOM( '\ufeffbeep' ); 45 // returns 'beep' 46 ``` 47 48 </section> 49 50 <!-- /.usage --> 51 52 <section class="examples"> 53 54 ## Examples 55 56 <!-- eslint no-undef: "error" --> 57 58 ```javascript 59 var removeUTF8BOM = require( '@stdlib/string/remove-utf8-bom' ); 60 61 var str = removeUTF8BOM( '\ufeffbeep' ); 62 // returns 'beep' 63 64 str = removeUTF8BOM( 'boop\ufeff' ); 65 // returns 'boop\ufeff' 66 67 str = removeUTF8BOM( 'be\ufeffbop' ); 68 // returns 'be\ufeffbop' 69 70 str = removeUTF8BOM( 'foobar' ); 71 // returns 'foobar' 72 ``` 73 74 </section> 75 76 <!-- /.examples --> 77 78 * * * 79 80 <section class="cli"> 81 82 ## CLI 83 84 <section class="usage"> 85 86 ### Usage 87 88 ```text 89 Usage: remove-utf8-bom [options] [<string>] 90 91 Options: 92 93 -h, --help Print this message. 94 -V, --version Print the package version. 95 ``` 96 97 </section> 98 99 <!-- /.usage --> 100 101 <section class="examples"> 102 103 ### Examples 104 105 Assuming a shell which understands escape sequences, 106 107 ```bash 108 $ remove-utf8-bom "\xEF\xBB\xBFbeep boop" 109 beep boop 110 ``` 111 112 To use as a [standard stream][standard-streams], 113 114 ```bash 115 $ echo -n '\ufeffbeep' | remove-utf8-bom 116 beep 117 ``` 118 119 </section> 120 121 <!-- /.examples --> 122 123 </section> 124 125 <!-- /.cli --> 126 127 <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> 128 129 <section class="related"> 130 131 </section> 132 133 <!-- /.related --> 134 135 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 136 137 <section class="links"> 138 139 [bom]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8 140 141 [standard-streams]: https://en.wikipedia.org/wiki/Standard_streams 142 143 </section> 144 145 <!-- /.links -->