From 1479659c46dcda19f3dae51491fcd5ed1af2a09b Mon Sep 17 00:00:00 2001 From: Sam Thorogood Date: Fri, 6 Mar 2020 14:26:46 +1100 Subject: [PATCH] support utf8 as well as utf-8 --- text.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/text.js b/text.js index cae81dd..a43d755 100644 --- a/text.js +++ b/text.js @@ -33,7 +33,7 @@ if (scope['TextEncoder'] && scope['TextDecoder']) { * @param {string=} utfLabel */ function FastTextEncoder(utfLabel='utf-8') { - if (utfLabel !== 'utf-8') { + if (utfLabel !== 'utf-8' && utfLabel !== 'utf8') { throw new RangeError( `Failed to construct 'TextEncoder': The encoding label provided ('${utfLabel}') is invalid.`); } @@ -114,7 +114,7 @@ FastTextEncoder.prototype.encode = function(string, options={stream: false}) { * @param {{fatal: boolean}=} options */ function FastTextDecoder(utfLabel='utf-8', options={fatal: false}) { - if (utfLabel !== 'utf-8') { + if (utfLabel !== 'utf-8' && utfLabel !== 'utf8') { throw new RangeError( `Failed to construct 'TextDecoder': The encoding label provided ('${utfLabel}') is invalid.`); }