This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const decodedResponse = await fetch('https://www.anysite.rss.xml', { | |
| headers: { | |
| 'Content-Type': 'text/xml;charset=ISO-8859-1', | |
| }, | |
| }) | |
| .then(r => r.arrayBuffer()) // resolve the response stream for buffer | |
| .then(d => { | |
| const dataView = new DataView(d); // creates a DataView object representing the buffer data | |
| const isoDecoder = new TextDecoder('ISO-8859-1'); // creates an instance of the our decoder | |
| const decodedString = isoDecoder.decode(dataView); // so we pass the stream of bytes for the decoder do its job |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) { | |
| // path/to/whatever does not exist | |
| } | |
| if _, err := os.Stat("/path/to/whatever"); err == nil { | |
| // path/to/whatever exists | |
| } |