Skip to content

Instantly share code, notes, and snippets.

// RN's fetch seems to not handling responses with other charsets correctly like Node.js does
// eg. the following link returns content-type: "text/html; charset=ISO-8859-1"
// https://www.corriere.it/cronache/20_marzo_13/coronavirus-ultimi-aggiornamenti-dall-italia-mondo-d4c07168-64f4-11ea-ac89-181bb7c2e00e.shtml
// response.text() resolves to undefined
const src = await fetch(url)
.then(response => {
const charset = (response.headers.get("content-type") || "").split(
"charset="
)[1];
if (!charset || charset.toLowerCase() === "utf-8") {
@dseg
dseg / sfen-parser.pegjs
Created March 8, 2016 14:33
sfen-parser.pegjs
/**
* Title: SFEN parser
* Date: 23-Jan-2014
* Author: Daichi Shinozaki <[email protected]>
* Demo URL: http://jsfiddle.net/dseg/QezQ7/15/
*
* Note:
* Tested with PEG.js 0.8.0
* http://pegjs.majda.cz/
*