From 52175eb4c973e4189c98d9befcacad776c5eebe9 Mon Sep 17 00:00:00 2001 From: polygonplanet Date: Sun, 9 Jun 2024 00:36:10 +0900 Subject: [PATCH] feat: v2.2.0 --- README.md | 2 +- README_ja.md | 2 +- encoding.js | 6 ++++-- encoding.min.js | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f910222..9fd3393 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ When the script is loaded, the object `Encoding` is defined in the global scope You can use encoding.js (package name: `encoding-japanese`) directly from a CDN via a script tag: ```html - + ``` In this example we use [unpkg](https://unpkg.com/encoding-japanese/), but you can use any CDN that provides npm packages, diff --git a/README_ja.md b/README_ja.md index e6d83f0..71deec2 100644 --- a/README_ja.md +++ b/README_ja.md @@ -114,7 +114,7 @@ minify された `encoding.min.js` も使用できます。 ` + ``` この例では [unpkg](https://unpkg.com/encoding-japanese/) を使用していますが、 diff --git a/encoding.js b/encoding.js index 9442071..f75b6e8 100644 --- a/encoding.js +++ b/encoding.js @@ -1,12 +1,12 @@ /*! - * encoding-japanese v2.1.0 - Convert and detect character encoding in JavaScript + * encoding-japanese v2.2.0 - Convert and detect character encoding in JavaScript * Copyright (c) 2012 polygonplanet * https://github.com/polygonplanet/encoding.js * @license MIT */ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Encoding = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i * https://github.com/polygonplanet/encoding.js * @license MIT */ -!function(n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Encoding=n()}(function(){return function r(o,i,l){function f(e,n){if(!i[e]){if(!o[e]){var t="function"==typeof require&&require;if(!n&&t)return t(e,!0);if(u)return u(e,!0);throw(n=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",n}t=i[e]={exports:{}},o[e][0].call(t.exports,function(n){return f(o[e][1][n]||n)},t,t.exports,r,o,i,l)}return i[e].exports}for(var u="function"==typeof require&&require,n=0;n>6&3,o=128|63&t,i[i.length]=239,i[i.length]=255&r,i[i.length]=255&o):128<=e?(r=e<<1,(t=n[++l])<159?(r-=r<319?225:97,t-=126>16&255),i[i.length]=o>>8&255,i[i.length]=255&o)):i[i.length]=255&n[l];return i}function o(n){a.init_JIS_TO_UTF8_TABLE();for(var e,t,r,o,i,l=[],f=0,u=n&&n.length;f>6&3,r=128|63&r,l[l.length]=239,l[l.length]=255&t,l[l.length]=255&r):143===e?(t=n[++f]-128,r=n[++f]-128,void 0===(i=c.JISX0212_TO_UTF8_TABLE[o=(t<<8)+r])?l[l.length]=a.FALLBACK_CHARACTER:(i<65535||(l[l.length]=i>>16&255),l[l.length]=i>>8&255,l[l.length]=255&i)):128<=e?(o=(e-128<<8)+(n[++f]-128),void 0===(i=c.JIS_TO_UTF8_TABLE[o])?l[l.length]=a.FALLBACK_CHARACTER:(i<65535||(l[l.length]=i>>16&255),l[l.length]=i>>8&255,l[l.length]=255&i)):l[l.length]=255&n[f];return l}function i(n){a.init_JIS_TO_UTF8_TABLE();for(var e,t,r,o,i=[],l=0,f=0,u=n&&n.length;f>16&255),i[i.length]=o>>8&255,i[i.length]=255&o)):2===l?(e=188|(t=n[f]+64)>>6&3,t=128|63&t,i[i.length]=239,i[i.length]=255&e,i[i.length]=255&t):3===l?(r=(n[f]<<8)+n[++f],void 0===(o=c.JISX0212_TO_UTF8_TABLE[r])?i[i.length]=a.FALLBACK_CHARACTER:(o<65535||(i[i.length]=o>>16&255),i[i.length]=o>>8&255,i[i.length]=255&o)):i[i.length]=255&n[f]}return i}function l(n,e){for(var t,r,o,i=[],l=0,f=n&&n.length,u=e&&e.fallback;l>8)?((o>>=1)<47?o+=113:o-=79,t+=95>=1)<=47?o+=112:o-=80,t+=126),i[i.length]=255&o,i[i.length]=255&t)):i[i.length]=255&n[l];return i}function f(n,e){for(var t,r,o,i=[],l=0,f=n&&n.length,u=e&&e.fallback;l>8)-128&255,i[i.length]=(255&o)-128&255):(65536>8)-128&255,i[i.length]=(255&o)-128&255))):i[i.length]=255&n[l];return i}function h(n,e){for(var t,r,o,i=[],l=0,f=n&&n.length,u=0,g=e&&e.fallback,h=[27,40,66,27,36,66,27,40,73,27,36,40,68];u>8&255,i[i.length]=255&o):(65536>8&255),i[i.length]=255&o));return 0!==l&&(i[i.length]=h[0],i[i.length]=h[1],i[i.length]=h[2]),i}function T(n){for(var e,t,r=[],o=0,i=n&&n.length;o>6&31,r[r.length]=128|63&e):e<65536?(r[r.length]=224|e>>12&15,r[r.length]=128|e>>6&63,r[r.length]=128|63&e):e<2097152&&(r[r.length]=240|e>>18&15,r[r.length]=128|e>>12&63,r[r.length]=128|e>>6&63,r[r.length]=128|63&e);return r}function s(n,e){for(var t,r,o,i=[],l=0,f=n&&n.length,u=e&&e.ignoreSurrogatePair;l>4)&&t<=7?o=r:12==t||13==t?o=(31&r)<<6|63&n[l++]:14==t?o=(15&r)<<12|(63&n[l++])<<6|63&n[l++]:15==t&&(o=(7&r)<<18|(63&n[l++])<<12|(63&n[l++])<<6|63&n[l++]),o<=65535||u?i[i.length]=o:(i[i.length]=55296+((o-=65536)>>10),i[i.length]=o%1024+56320);return i}function A(n,e){var t;if(e&&e.bom){var r,e=e.bom,o=("B"===(e=g.isString(e)?e:"BE").charAt(0).toUpperCase()?(r=[254,255],E):(r=[255,254],_))(n);(t=[])[0]=r[0],t[1]=r[1];for(var i=0,l=o.length;i>8&255,t[t.length]=255&e);return t}function _(n){for(var e,t=[],r=0,o=n&&n.length;r>8&255);return t}function U(n){var e,t,r=[],o=0,i=n&&n.length;for(2<=i&&(254===n[0]&&255===n[1]||255===n[0]&&254===n[1])&&(o=2);o>=1)<47?e+=113:e-=79,t+=95>=1)<=47?e+=112:e-=80,t+=126),r[r.length]=255&e,r[r.length]=255&t):r[r.length]=2===o?n[i]+128&255:3===o?a.FALLBACK_CHARACTER:255&n[i]}return r},t.JISToEUCJP=function(n){for(var e=[],t=0,r=n&&n.length,o=0;o>=1)+(e<111?49:113),t-=223>=1)+(e<=111?48:112),t-=2),r[r.length]=255&e,r[r.length]=255&t):r[r.length]=142===e?255&n[++i]:255&e;return r},t.SJISToUTF8=r,t.EUCJPToUTF8=o,t.JISToUTF8=i,t.UTF8ToSJIS=l,t.UTF8ToEUCJP=f,t.UTF8ToJIS=h,t.UNICODEToUTF8=T,t.UTF8ToUNICODE=s,t.UNICODEToUTF16=A,t.UNICODEToUTF16BE=E,t.UNICODEToUTF16LE=_,t.UTF16BEToUNICODE=U,t.UTF16LEToUNICODE=S,t.UTF16ToUNICODE=F,t.UTF16ToUTF16BE=function(n){for(var e,t,r=[],o=0,i=n&&n.length,l=!1,f=!0;o>4&15],r[r.length]=t[15&e]))}return u.codeToString_fast(r)},urlDecode:function(n){for(var e,t=[],r=0,o=n&&n.length;rh.APPLY_BUFFER_SIZE&&(h.APPLY_BUFFER_SIZE_OK=!0),t}catch(n){h.APPLY_BUFFER_SIZE_OK=!1}}return s(n)}function s(n){for(var e,t="",r=n&&n.length,o=0;oh.APPLY_BUFFER_SIZE&&(h.APPLY_BUFFER_SIZE_OK=!0);continue}catch(n){h.APPLY_BUFFER_SIZE_OK=!1}return A(n)}t+=i.apply(null,e)}return t}function A(n){for(var e="",t=n&&n.length,r=0;r>2],l[l.length]=E[(3&e)<<4],l[l.length]=U,l[l.length]=U;break}if(t=n[i++],i==o){l[l.length]=E[e>>2],l[l.length]=E[(3&e)<<4|(240&t)>>4],l[l.length]=E[(15&t)<<2],l[l.length]=U;break}r=n[i++],l[l.length]=E[e>>2],l[l.length]=E[(3&e)<<4|(240&t)>>4],l[l.length]=E[(15&t)<<2|(192&r)>>6],l[l.length]=E[63&r]}return T(l)},t.base64decode=function(n){for(var e,t,r,o,i=n&&n.length,l=0,f=[];l>4;do{if(61==(r=255&n.charCodeAt(l++)))return f}while(r=_[r],l>2;do{if(61==(o=255&n.charCodeAt(l++)))return f}while(o=_[o],l>6&3,o=128|63&t,i[i.length]=239,i[i.length]=255&r,i[i.length]=255&o):128<=e?(r=e<<1,(t=n[++l])<159?(r-=r<319?225:97,t-=126>16&255),i[i.length]=o>>8&255,i[i.length]=255&o)):i[i.length]=255&n[l];return i}function o(n){a.init_JIS_TO_UTF8_TABLE();for(var e,t,r,o,i,l=[],f=0,u=n&&n.length;f>6&3,r=128|63&r,l[l.length]=239,l[l.length]=255&t,l[l.length]=255&r):143===e?(t=n[++f]-128,r=n[++f]-128,void 0===(i=c.JISX0212_TO_UTF8_TABLE[o=(t<<8)+r])?l[l.length]=a.FALLBACK_CHARACTER:(i<65535||(l[l.length]=i>>16&255),l[l.length]=i>>8&255,l[l.length]=255&i)):128<=e?(o=(e-128<<8)+(n[++f]-128),void 0===(i=c.JIS_TO_UTF8_TABLE[o])?l[l.length]=a.FALLBACK_CHARACTER:(i<65535||(l[l.length]=i>>16&255),l[l.length]=i>>8&255,l[l.length]=255&i)):l[l.length]=255&n[f];return l}function i(n){a.init_JIS_TO_UTF8_TABLE();for(var e,t,r,o,i=[],l=0,f=0,u=n&&n.length;f>16&255),i[i.length]=o>>8&255,i[i.length]=255&o)):2===l?(e=188|(t=n[f]+64)>>6&3,t=128|63&t,i[i.length]=239,i[i.length]=255&e,i[i.length]=255&t):3===l?(r=(n[f]<<8)+n[++f],void 0===(o=c.JISX0212_TO_UTF8_TABLE[r])?i[i.length]=a.FALLBACK_CHARACTER:(o<65535||(i[i.length]=o>>16&255),i[i.length]=o>>8&255,i[i.length]=255&o)):i[i.length]=255&n[f]}return i}function l(n,e){for(var t,r,o,i=[],l=0,f=n&&n.length,u=e&&e.fallback;l>8)?((o>>=1)<47?o+=113:o-=79,t+=95>=1)<=47?o+=112:o-=80,t+=126),i[i.length]=255&o,i[i.length]=255&t)):i[i.length]=255&n[l];return i}function f(n,e){for(var t,r,o,i=[],l=0,f=n&&n.length,u=e&&e.fallback;l>8)-128&255,i[i.length]=(255&o)-128&255):(65536>8)-128&255,i[i.length]=(255&o)-128&255))):i[i.length]=255&n[l];return i}function h(n,e){for(var t,r,o,i=[],l=0,f=n&&n.length,u=0,g=e&&e.fallback,h=[27,40,66,27,36,66,27,40,73,27,36,40,68];u>8&255,i[i.length]=255&o):(65536>8&255),i[i.length]=255&o));return 0!==l&&(i[i.length]=h[0],i[i.length]=h[1],i[i.length]=h[2]),i}function T(n){for(var e,t,r=[],o=0,i=n&&n.length;o>6&31,r[r.length]=128|63&e):e<65536?(r[r.length]=224|e>>12&15,r[r.length]=128|e>>6&63,r[r.length]=128|63&e):e<2097152&&(r[r.length]=240|e>>18&15,r[r.length]=128|e>>12&63,r[r.length]=128|e>>6&63,r[r.length]=128|63&e);return r}function s(n,e){for(var t,r,o,i=[],l=0,f=n&&n.length,u=e&&e.ignoreSurrogatePair;l>4)&&t<=7?o=r:12==t||13==t?o=(31&r)<<6|63&n[l++]:14==t?o=(15&r)<<12|(63&n[l++])<<6|63&n[l++]:15==t&&(o=(7&r)<<18|(63&n[l++])<<12|(63&n[l++])<<6|63&n[l++]),o<=65535||u?i[i.length]=o:(i[i.length]=55296+((o-=65536)>>10),i[i.length]=o%1024+56320);return i}function A(n,e){var t;if(e&&e.bom){var r,e=e.bom,o=("B"===(e=g.isString(e)?e:"BE").charAt(0).toUpperCase()?(r=[254,255],E):(r=[255,254],_))(n);(t=[])[0]=r[0],t[1]=r[1];for(var i=0,l=o.length;i>8&255,t[t.length]=255&e);return t}function _(n){for(var e,t=[],r=0,o=n&&n.length;r>8&255);return t}function U(n){var e,t,r=[],o=0,i=n&&n.length;for(2<=i&&(254===n[0]&&255===n[1]||255===n[0]&&254===n[1])&&(o=2);o>=1)<47?e+=113:e-=79,t+=95>=1)<=47?e+=112:e-=80,t+=126),r[r.length]=255&e,r[r.length]=255&t):r[r.length]=2===o?n[i]+128&255:3===o?a.FALLBACK_CHARACTER:255&n[i]}return r},t.JISToEUCJP=function(n){for(var e=[],t=0,r=n&&n.length,o=0;o>=1)+(e<111?49:113),t-=223>=1)+(e<=111?48:112),t-=2),r[r.length]=255&e,r[r.length]=255&t):r[r.length]=142===e?255&n[++i]:255&e;return r},t.SJISToUTF8=r,t.EUCJPToUTF8=o,t.JISToUTF8=i,t.UTF8ToSJIS=l,t.UTF8ToEUCJP=f,t.UTF8ToJIS=h,t.UNICODEToUTF8=T,t.UTF8ToUNICODE=s,t.UNICODEToUTF16=A,t.UNICODEToUTF16BE=E,t.UNICODEToUTF16LE=_,t.UTF16BEToUNICODE=U,t.UTF16LEToUNICODE=S,t.UTF16ToUNICODE=F,t.UTF16ToUTF16BE=function(n){for(var e,t,r=[],o=0,i=n&&n.length,l=!1,f=!0;o>4&15],r[r.length]=t[15&e]))}return u.codeToString_fast(r)},urlDecode:function(n){for(var e,t=[],r=0,o=n&&n.length;rh.APPLY_BUFFER_SIZE&&(h.APPLY_BUFFER_SIZE_OK=!0),t}catch(n){h.APPLY_BUFFER_SIZE_OK=!1}}return s(n)}function s(n){for(var e,t="",r=n&&n.length,o=0;oh.APPLY_BUFFER_SIZE&&(h.APPLY_BUFFER_SIZE_OK=!0);continue}catch(n){h.APPLY_BUFFER_SIZE_OK=!1}return A(n)}t+=i.apply(null,e)}return t}function A(n){for(var e="",t=n&&n.length,r=0;r>2],l[l.length]=E[(3&e)<<4],l[l.length]=U,l[l.length]=U;break}if(t=n[i++],i==o){l[l.length]=E[e>>2],l[l.length]=E[(3&e)<<4|(240&t)>>4],l[l.length]=E[(15&t)<<2],l[l.length]=U;break}r=n[i++],l[l.length]=E[e>>2],l[l.length]=E[(3&e)<<4|(240&t)>>4],l[l.length]=E[(15&t)<<2|(192&r)>>6],l[l.length]=E[63&r]}return T(l)},t.base64decode=function(n){for(var e,t,r,o,i=n&&n.length,l=0,f=[];l>4;do{if(61==(r=255&n.charCodeAt(l++)))return f}while(r=_[r],l>2;do{if(61==(o=255&n.charCodeAt(l++)))return f}while(o=_[o],l