Intial Commit
This commit is contained in:
1
nodered/rootfs/data/node_modules/encoding-japanese/tests/encoding-eucjp.txt
generated
vendored
Normal file
1
nodered/rootfs/data/node_modules/encoding-japanese/tests/encoding-eucjp.txt
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD>Υƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD> EUC-JP <20>ǽ<C7BD><F1A4ABA4>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD>
|
||||
1
nodered/rootfs/data/node_modules/encoding-japanese/tests/encoding-jis.txt
generated
vendored
Normal file
1
nodered/rootfs/data/node_modules/encoding-japanese/tests/encoding-jis.txt
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
$B$3$N%F%-%9%H$O(B JIS $B$G=q$+$l$F$$$^$9!#(B
|
||||
1
nodered/rootfs/data/node_modules/encoding-japanese/tests/encoding-sjis.txt
generated
vendored
Normal file
1
nodered/rootfs/data/node_modules/encoding-japanese/tests/encoding-sjis.txt
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD>̃e<EFBFBD>L<EFBFBD>X<EFBFBD>g<EFBFBD><EFBFBD> SJIS <20>ŏ<EFBFBD><C58F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B
|
||||
1
nodered/rootfs/data/node_modules/encoding-japanese/tests/encoding-utf8.txt
generated
vendored
Normal file
1
nodered/rootfs/data/node_modules/encoding-japanese/tests/encoding-utf8.txt
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
このテキストは UTF-8 で書かれています。
|
||||
1
nodered/rootfs/data/node_modules/encoding-japanese/tests/jis-x-0208-utf8.txt
generated
vendored
Normal file
1
nodered/rootfs/data/node_modules/encoding-japanese/tests/jis-x-0208-utf8.txt
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
210
nodered/rootfs/data/node_modules/encoding-japanese/tests/jis-x-0212-sjis-to-utf8.txt
generated
vendored
Normal file
210
nodered/rootfs/data/node_modules/encoding-japanese/tests/jis-x-0212-sjis-to-utf8.txt
generated
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
JIS X 0212
|
||||
|
||||
????????~???????????№
|
||||
?????????????????????
|
||||
??????????????????????????
|
||||
???????????
|
||||
????????????????
|
||||
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????
|
||||
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
?????????????????????????
|
||||
|
||||
????????丨?????????????????????
|
||||
?????????仡?????????伀?伃????????
|
||||
??????伹??????????佖????????????
|
||||
??????侊???侒?侔??侚??????????????
|
||||
俉??俍?????????俿??????????????倞倢
|
||||
??????偀?偂?偆????????????????偰??
|
||||
??????????傔???????????????????
|
||||
????僘?????????????????????????
|
||||
?????????????????兊??????兤?????
|
||||
??冝??????冾????????????????????
|
||||
??刕???????????????????????????
|
||||
???????劜??劦?劯???????勀????????勛
|
||||
????????????匀?????????????????
|
||||
?????????????????卲??????厓?????
|
||||
???厲?????????????叝????????????
|
||||
?????????????????????????????咜
|
||||
????咩????????????????????哿????
|
||||
??????????????????????????????
|
||||
?喆????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
?坥????????????????????????????
|
||||
?????垬??埇埈????????????????????
|
||||
??????????????????????????????
|
||||
?????????????????墲????????????
|
||||
??????夋???????????????????奓?奛奝
|
||||
???奣????????????????妤???????妺?
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
?????????孖????????????????????
|
||||
????????寀?????寘?????????尞?????
|
||||
??????????????????????????????
|
||||
??岦????岺?????????????????崧????
|
||||
?嵂?????????????嵭??????????????
|
||||
???????嶸嶹???巐?????????????????
|
||||
??????????????????????????????
|
||||
?????????????????????????弡????
|
||||
????弴??????彅?????????彧????????
|
||||
?????????????????????????忞????
|
||||
??????????????????????????????
|
||||
??恝????????悊??????????????????
|
||||
???????惕???惞??惲?????????愑?????
|
||||
??????愰???愷???????????????????
|
||||
???憘??????????????????????????
|
||||
???????戓??????????????????????
|
||||
??????????抦???????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
?????????揵????????????????????
|
||||
???????????摠???????????????撝??
|
||||
?????????????擎????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??昀??昉???昕??昞???昤?????昮?昱?????
|
||||
?????晗?晙????曻????晳????????????
|
||||
?暙????暠???暲??暿??????????????曺?
|
||||
?朎??????????????杦?????????????
|
||||
??????枻???柀???????????????桒???
|
||||
???????????桄??????????????????
|
||||
?????????????????棈?棏??????????
|
||||
??????????????????????????????
|
||||
???楨????????????榘?????????????
|
||||
???槢??????????????????樰???????
|
||||
橆?????????????橳橾??????????????
|
||||
????????????????櫤?????????????
|
||||
??????????????????????????????
|
||||
?????????????????????毖????????
|
||||
??????????????????????氿???????
|
||||
?汜??汯??????沆??????????????????
|
||||
??泚?????????洄?????????????????
|
||||
??????浯???涇???涖???涬?????????淏?
|
||||
???????????淼????渧??渹?渼????????
|
||||
???湜??????????????????溿???????
|
||||
??????????????????????????????
|
||||
??????????????澈???????????????
|
||||
???澵???????????濵????瀅?瀇???????
|
||||
?????????????????????炅????????
|
||||
炫???????????????焄?????焏???????
|
||||
???煆煇??????煜??????????????????
|
||||
??燁?????????燾?????????????????
|
||||
??????????????????????????????
|
||||
??犱?犾?????????????????????????
|
||||
?猤???????????????????????????獷
|
||||
???????????????????????????玽??
|
||||
?珉???珒?珖???珣????珵?????????琇???
|
||||
??琦?琩琪???琮???????????????瑢????
|
||||
?????????璉????????璟???????????
|
||||
??????????????????????????????
|
||||
?????甯????????????????畯???????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
?????????????????????????皛皜???
|
||||
????皦?????????????????????????
|
||||
?????????????????????睆????????
|
||||
??????????????????????????????
|
||||
??????????????????????????砡???
|
||||
?????????硎??????硤???硺?????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
????????????????禔???禛?????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
???????????????????????竑???竫??
|
||||
??????????????????????????????
|
||||
????????????箞?????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
????????????????????????絈?????
|
||||
?絜????????????????????????????
|
||||
綷?????????????????????????????
|
||||
???????????????繒??????????????
|
||||
纊??????????????罇??????????????
|
||||
???????????羡??????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
???????茁??????????????????????
|
||||
???????????荿??????????????????
|
||||
??菇?????????菶???????????????葈?
|
||||
??????????????????????????????
|
||||
???蒴??????????蓜???????????????
|
||||
?????????????????????蕓?蕙??????
|
||||
??蕫???????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
????????????????裵???????????褜?
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
?????????訒???????????訷????????
|
||||
?????????????詹???????????????誧
|
||||
???????誾???????????諟????諶?????
|
||||
????????????????譓?????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??賰?????????贒?????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
????????軏?????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
?????????????????????遧????????
|
||||
??????????????????????????????
|
||||
????????????????????????????鄧?
|
||||
??????????????????????????????
|
||||
?????????????????????????????釗
|
||||
?釚釞釤釥???釭釮???????????鈆??鈊?鈐???
|
||||
???????????????鈹鈺鈼?鉀??????鉎?鉑?
|
||||
鉙?????鉧???????鉷鉸?????銈????????
|
||||
???銧???????????????????????鋐鋓鋕
|
||||
鋗?鋙???鋠???鋧????鋹鋻鋿?錂??????錝錞?錡
|
||||
?錥????????鍈?????鍗??????????鍰??
|
||||
????????????????????鎤?????????
|
||||
??鏆?????????鏞??????鏸??????????
|
||||
???????鐱???????鑅鑈?????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
?????????????????隝??????隯?????
|
||||
?????????????????????霳?靃??靏靕??
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
顗????顥????????????????????????
|
||||
??????????????餧???????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????驎???????????????????????
|
||||
????髜?????????????????????????
|
||||
??????????????????????????????
|
||||
??????魵?????????????鮏?????????
|
||||
?鮱???鮻????????????????????????
|
||||
鰀?????????????????????????????
|
||||
??????????????????????????????
|
||||
?????????????????????????鵫鵰???
|
||||
??????????????????????????????
|
||||
???????????????????????鸙??????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
??????????????????????????????
|
||||
???????????
|
||||
210
nodered/rootfs/data/node_modules/encoding-japanese/tests/jis-x-0212-utf8.txt
generated
vendored
Normal file
210
nodered/rootfs/data/node_modules/encoding-japanese/tests/jis-x-0212-utf8.txt
generated
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
JIS X 0212
|
||||
|
||||
˘ˇ¸˙˝¯˛˚~΄΅¡¦¿ºª©®™¤№
|
||||
ΆΈΉΊΪΌΎΫΏάέήίϊΐόςύϋΰώ
|
||||
ЂЃЄЅІЇЈЉЊЋЌЎЏђѓєѕіїјљњћќўџ
|
||||
ÆĐĦIJŁĿŊØŒŦÞ
|
||||
æđðħıijĸłŀʼnŋøœßŧþ
|
||||
|
||||
ÁÀÄÂĂǍĀĄÅÃĆĈČÇĊĎÉÈËÊĚĖĒĘĜĞĢĠĤÍ
|
||||
ÌÏÎǏİĪĮĨĴĶĹĽĻŃŇŅÑÓÒÖÔǑŐŌÕŔŘŖŚŜ
|
||||
ŠŞŤŢÚÙÜÛŬǓŰŪŲŮŨǗǛǙǕŴÝŸŶŹŽŻ
|
||||
|
||||
áàäâăǎāąåãćĉčçċďéèëêěėēęǵĝğġĥí
|
||||
ìïîǐīįĩĵķĺľļńňņñóòöôǒőōõŕřŗśŝš
|
||||
şťţúùüûŭǔűūųůũǘǜǚǖŵýÿŷźžż
|
||||
|
||||
丂丄丅丌丒丟丣两丨丫丮丯丰丵乀乁乄乇乑乚乜乣乨乩乴乵乹乿亍亖
|
||||
亗亝亯亹仃仐仚仛仠仡仢仨仯仱仳仵份仾仿伀伂伃伈伋伌伒伕伖众伙
|
||||
伮伱你伳伵伷伹伻伾佀佂佈佉佋佌佒佔佖佘佟佣佪佬佮佱佷佸佹佺佽
|
||||
佾侁侂侄侅侉侊侌侎侐侒侓侔侗侙侚侞侟侲侷侹侻侼侽侾俀俁俅俆俈
|
||||
俉俋俌俍俏俒俜俠俢俰俲俼俽俿倀倁倄倇倊倌倎倐倓倗倘倛倜倝倞倢
|
||||
倧倮倰倲倳倵偀偁偂偅偆偊偌偎偑偒偓偗偙偟偠偢偣偦偧偪偭偰偱倻
|
||||
傁傃傄傆傊傎傏傐傒傓傔傖傛傜傞傟傠傡傢傪傯傰傹傺傽僀僃僄僇僌
|
||||
僎僐僓僔僘僜僝僟僢僤僦僨僩僯僱僶僺僾儃儆儇儈儋儌儍儎僲儐儗儙
|
||||
儛儜儝儞儣儧儨儬儭儯儱儳儴儵儸儹兂兊兏兓兕兗兘兟兤兦兾冃冄冋
|
||||
冎冘冝冡冣冭冸冺冼冾冿凂凈减凑凒凓凕凘凞凢凥凮凲凳凴凷刁刂刅
|
||||
划刓刕刖刘刢刨刱刲刵刼剅剉剕剗剘剚剜剟剠剡剦剮剷剸剹劀劂劅劊
|
||||
劌劓劕劖劗劘劚劜劤劥劦劧劯劰劶劷劸劺劻劽勀勄勆勈勌勏勑勔勖勛
|
||||
勜勡勥勨勩勪勬勰勱勴勶勷匀匃匊匋匌匑匓匘匛匜匞匟匥匧匨匩匫匬
|
||||
匭匰匲匵匼匽匾卂卌卋卙卛卡卣卥卬卭卲卹卾厃厇厈厎厓厔厙厝厡厤
|
||||
厪厫厯厲厴厵厷厸厺厽叀叅叏叒叓叕叚叝叞叠另叧叵吂吓吚吡吧吨吪
|
||||
启吱吴吵呃呄呇呍呏呞呢呤呦呧呩呫呭呮呴呿咁咃咅咈咉咍咑咕咖咜
|
||||
咟咡咦咧咩咪咭咮咱咷咹咺咻咿哆哊响哎哠哪哬哯哶哼哾哿唀唁唅唈
|
||||
唉唌唍唎唕唪唫唲唵唶唻唼唽啁啇啉啊啍啐啑啘啚啛啞啠啡啤啦啿喁
|
||||
喂喆喈喎喏喑喒喓喔喗喣喤喭喲喿嗁嗃嗆嗉嗋嗌嗎嗑嗒嗓嗗嗘嗛嗞嗢
|
||||
嗩嗶嗿嘅嘈嘊嘍嘎嘏嘐嘑嘒嘙嘬嘰嘳嘵嘷嘹嘻嘼嘽嘿噀噁噃噄噆噉噋
|
||||
噍噏噔噞噠噡噢噣噦噩噭噯噱噲噵嚄嚅嚈嚋嚌嚕嚙嚚嚝嚞嚟嚦嚧嚨嚩
|
||||
嚫嚬嚭嚱嚳嚷嚾囅囉囊囋囏囐囌囍囙囜囝囟囡囤囥囦囧囨囱囫园囶囷
|
||||
圁圂圇圊圌圑圕圚圛圝圠圢圣圤圥圩圪圬圮圯圳圴圽圾圿坅坆坌坍坒
|
||||
坢坥坧坨坫坭坮坯坰坱坳坴坵坷坹坺坻坼坾垁垃垌垔垗垙垚垜垝垞垟
|
||||
垡垕垧垨垩垬垸垽埇埈埌埏埕埝埞埤埦埧埩埭埰埵埶埸埽埾埿堃堄堈
|
||||
堉埡堌堍堛堞堟堠堦堧堭堲堹堿塉塌塍塏塐塕塟塡塤塧塨塸塼塿墀墁
|
||||
墇墈墉墊墌墍墏墐墔墖墝墠墡墢墦墩墱墲壄墼壂壈壍壎壐壒壔壖壚壝
|
||||
壡壢壩壳夅夆夋夌夒夓夔虁夝夡夣夤夨夯夰夳夵夶夿奃奆奒奓奙奛奝
|
||||
奞奟奡奣奫奭奯奲奵奶她奻奼妋妌妎妒妕妗妟妤妧妭妮妯妰妳妷妺妼
|
||||
姁姃姄姈姊姍姒姝姞姟姣姤姧姮姯姱姲姴姷娀娄娌娍娎娒娓娞娣娤娧
|
||||
娨娪娭娰婄婅婇婈婌婐婕婞婣婥婧婭婷婺婻婾媋媐媓媖媙媜媞媟媠媢
|
||||
媧媬媱媲媳媵媸媺媻媿嫄嫆嫈嫏嫚嫜嫠嫥嫪嫮嫵嫶嫽嬀嬁嬈嬗嬴嬙嬛
|
||||
嬝嬡嬥嬭嬸孁孋孌孒孖孞孨孮孯孼孽孾孿宁宄宆宊宎宐宑宓宔宖宨宩
|
||||
宬宭宯宱宲宷宺宼寀寁寍寏寖寗寘寙寚寠寯寱寴寽尌尗尞尟尣尦尩尫
|
||||
尬尮尰尲尵尶屙屚屜屢屣屧屨屩屭屰屴屵屺屻屼屽岇岈岊岏岒岝岟岠
|
||||
岢岣岦岪岲岴岵岺峉峋峒峝峗峮峱峲峴崁崆崍崒崫崣崤崦崧崱崴崹崽
|
||||
崿嵂嵃嵆嵈嵕嵑嵙嵊嵟嵠嵡嵢嵤嵪嵭嵰嵹嵺嵾嵿嶁嶃嶈嶊嶒嶓嶔嶕嶙
|
||||
嶛嶟嶠嶧嶫嶰嶴嶸嶹巃巇巋巐巎巘巙巠巤巩巸巹帀帇帍帒帔帕帘帟帠
|
||||
帮帨帲帵帾幋幐幉幑幖幘幛幜幞幨幪幫幬幭幮幰庀庋庎庢庤庥庨庪庬
|
||||
庱庳庽庾庿廆廌廋廎廑廒廔廕廜廞廥廫异弆弇弈弎弙弜弝弡弢弣弤弨
|
||||
弫弬弮弰弴弶弻弽弿彀彄彅彇彍彐彔彘彛彠彣彤彧彯彲彴彵彸彺彽彾
|
||||
徉徍徏徖徜徝徢徧徫徤徬徯徰徱徸忄忇忈忉忋忐忑忒忓忔忞忡忢忨忩
|
||||
忪忬忭忮忯忲忳忶忺忼怇怊怍怓怔怗怘怚怟怤怭怳怵恀恇恈恉恌恑恔
|
||||
恖恗恝恡恧恱恾恿悂悆悈悊悎悑悓悕悘悝悞悢悤悥您悰悱悷悻悾惂惄
|
||||
惈惉惊惋惎惏惔惕惙惛惝惞惢惥惲惵惸惼惽愂愇愊愌愐愑愒愓愔愖愗
|
||||
愙愜愞愢愪愫愰愱愵愶愷愹慁慅慆慉慞慠慬慲慸慻慼慿憀憁憃憄憋憍
|
||||
憒憓憗憘憜憝憟憠憥憨憪憭憸憹憼懀懁懂懎懏懕懜懝懞懟懡懢懧懩懥
|
||||
懬懭懯戁戃戄戇戓戕戜戠戢戣戧戩戫戹戽扂扃扄扆扌扐扑扒扔扖扚扜
|
||||
扤扭扯扳扺扽抍抎抏抐抦抨抳抶抷抺抾抿拄拎拕拖拚拪拲拴拼拽挃挄
|
||||
挊挋挍挐挓挖挘挩挪挭挵挶挹挼捁捂捃捄捆捊捋捎捒捓捔捘捛捥捦捬
|
||||
捭捱捴捵捸捼捽捿掂掄掇掊掐掔掕掙掚掞掤掦掭掮掯掽揁揅揈揎揑揓
|
||||
揔揕揜揠揥揪揬揲揳揵揸揹搉搊搐搒搔搘搞搠搢搤搥搩搪搯搰搵搽搿
|
||||
摋摏摑摒摓摔摚摛摜摝摟摠摡摣摭摳摴摻摽撅撇撏撐撑撘撙撛撝撟撡
|
||||
撣撦撨撬撳撽撾撿擄擉擊擋擌擎擐擑擕擗擤擥擩擪擭擰擵擷擻擿攁攄
|
||||
攈攉攊攏攓攔攖攙攛攞攟攢攦攩攮攱攺攼攽敃敇敉敐敒敔敟敠敧敫敺
|
||||
敽斁斅斊斒斕斘斝斠斣斦斮斲斳斴斿旂旈旉旎旐旔旖旘旟旰旲旴旵旹
|
||||
旾旿昀昄昈昉昍昑昒昕昖昝昞昡昢昣昤昦昩昪昫昬昮昰昱昳昹昷晀晅
|
||||
晆晊晌晑晎晗晘晙晛晜晠晡曻晪晫晬晾晳晵晿晷晸晹晻暀晼暋暌暍暐
|
||||
暒暙暚暛暜暟暠暤暭暱暲暵暻暿曀曂曃曈曌曎曏曔曛曟曨曫曬曮曺朅
|
||||
朇朎朓朙朜朠朢朳朾杅杇杈杌杔杕杝杦杬杮杴杶杻极构枎枏枑枓枖枘
|
||||
枙枛枰枱枲枵枻枼枽柹柀柂柃柅柈柉柒柗柙柜柡柦柰柲柶柷桒栔栙栝
|
||||
栟栨栧栬栭栯栰栱栳栻栿桄桅桊桌桕桗桘桛桫桮桯桰桱桲桵桹桺桻桼
|
||||
梂梄梆梈梖梘梚梜梡梣梥梩梪梮梲梻棅棈棌棏棐棑棓棖棙棜棝棥棨棪
|
||||
棫棬棭棰棱棵棶棻棼棽椆椉椊椐椑椓椖椗椱椳椵椸椻楂楅楉楎楗楛楣
|
||||
楤楥楦楨楩楬楰楱楲楺楻楿榀榍榒榖榘榡榥榦榨榫榭榯榷榸榺榼槅槈
|
||||
槑槖槗槢槥槮槯槱槳槵槾樀樁樃樏樑樕樚樝樠樤樨樰樲樴樷樻樾樿橅
|
||||
橆橉橊橎橐橑橒橕橖橛橤橧橪橱橳橾檁檃檆檇檉檋檑檛檝檞檟檥檫檯
|
||||
檰檱檴檽檾檿櫆櫉櫈櫌櫐櫔櫕櫖櫜櫝櫤櫧櫬櫰櫱櫲櫼櫽欂欃欆欇欉欏
|
||||
欐欑欗欛欞欤欨欫欬欯欵欶欻欿歆歊歍歒歖歘歝歠歧歫歮歰歵歽歾殂
|
||||
殅殗殛殟殠殢殣殨殩殬殭殮殰殸殹殽殾毃毄毉毌毖毚毡毣毦毧毮毱毷
|
||||
毹毿氂氄氅氉氍氎氐氒氙氟氦氧氨氬氮氳氵氶氺氻氿汊汋汍汏汒汔汙
|
||||
汛汜汫汭汯汴汶汸汹汻沅沆沇沉沔沕沗沘沜沟沰沲沴泂泆泍泏泐泑泒
|
||||
泔泖泚泜泠泧泩泫泬泮泲泴洄洇洊洎洏洑洓洚洦洧洨汧洮洯洱洹洼洿
|
||||
浗浞浟浡浥浧浯浰浼涂涇涑涒涔涖涗涘涪涬涴涷涹涽涿淄淈淊淎淏淖
|
||||
淛淝淟淠淢淥淩淯淰淴淶淼渀渄渞渢渧渲渶渹渻渼湄湅湈湉湋湏湑湒
|
||||
湓湔湗湜湝湞湢湣湨湳湻湽溍溓溙溠溧溭溮溱溳溻溿滀滁滃滇滈滊滍
|
||||
滎滏滫滭滮滹滻滽漄漈漊漌漍漖漘漚漛漦漩漪漯漰漳漶漻漼漭潏潑潒
|
||||
潓潗潙潚潝潞潡潢潨潬潽潾澃澇澈澋澌澍澐澒澓澔澖澚澟澠澥澦澧澨
|
||||
澮澯澰澵澶澼濅濇濈濊濚濞濨濩濰濵濹濼濽瀀瀅瀆瀇瀍瀗瀠瀣瀯瀴瀷
|
||||
瀹瀼灃灄灈灉灊灋灔灕灝灞灎灤灥灬灮灵灶灾炁炅炆炔炕炖炗炘炛炤
|
||||
炫炰炱炴炷烊烑烓烔烕烖烘烜烤烺焃焄焅焆焇焋焌焏焞焠焫焭焯焰焱
|
||||
焸煁煅煆煇煊煋煐煒煗煚煜煞煠煨煹熀熅熇熌熒熚熛熠熢熯熰熲熳熺
|
||||
熿燀燁燄燋燌燓燖燙燚燜燸燾爀爇爈爉爓爗爚爝爟爤爫爯爴爸爹牁牂
|
||||
牃牅牎牏牐牓牕牖牚牜牞牠牣牨牫牮牯牱牷牸牻牼牿犄犉犍犎犓犛犨
|
||||
犭犮犱犴犾狁狇狉狌狕狖狘狟狥狳狴狺狻狾猂猄猅猇猋猍猒猓猘猙猞
|
||||
猢猤猧猨猬猱猲猵猺猻猽獃獍獐獒獖獘獝獞獟獠獦獧獩獫獬獮獯獱獷
|
||||
獹獼玀玁玃玅玆玎玐玓玕玗玘玜玞玟玠玢玥玦玪玫玭玵玷玹玼玽玿珅
|
||||
珆珉珋珌珏珒珓珖珙珝珡珣珦珧珩珴珵珷珹珺珻珽珿琀琁琄琇琊琑琚
|
||||
琛琤琦琨琩琪琫琬琭琮琯琰琱琹瑀瑃瑄瑆瑇瑋瑍瑑瑒瑗瑝瑢瑦瑧瑨瑫
|
||||
瑭瑮瑱瑲璀璁璅璆璇璉璏璐璑璒璘璙璚璜璟璠璡璣璦璨璩璪璫璮璯璱
|
||||
璲璵璹璻璿瓈瓉瓌瓐瓓瓘瓚瓛瓞瓟瓤瓨瓪瓫瓯瓴瓺瓻瓼瓿甆甒甖甗甠
|
||||
甡甤甧甩甪甯甶甹甽甾甿畀畃畇畈畎畐畒畗畞畟畡畯畱畹畺畻畼畽畾
|
||||
疁疅疐疒疓疕疙疜疢疤疴疺疿痀痁痄痆痌痎痏痗痜痟痠痡痤痧痬痮痯
|
||||
痱痹瘀瘂瘃瘄瘇瘈瘊瘌瘏瘒瘓瘕瘖瘙瘛瘜瘝瘞瘣瘥瘦瘩瘭瘲瘳瘵瘸瘹
|
||||
瘺瘼癊癀癁癃癄癅癉癋癕癙癟癤癥癭癮癯癱癴皁皅皌皍皕皛皜皝皟皠
|
||||
皢皣皤皥皦皧皨皪皭皽盁盅盉盋盌盎盔盙盠盦盨盬盰盱盶盹盼眀眆眊
|
||||
眎眒眔眕眗眙眚眜眢眨眭眮眯眴眵眶眹眽眾睂睅睆睊睍睎睏睒睖睗睜
|
||||
睞睟睠睢睤睧睪睬睰睲睳睴睺睽瞀瞄瞌瞍瞔瞕瞖瞚瞟瞢瞧瞪瞮瞯瞱瞵
|
||||
瞾矃矉矑矒矕矙矞矟矠矤矦矪矬矰矱矴矸矻砅砆砉砍砎砑砝砡砢砣砭
|
||||
砮砰砵砷硃硄硇硈硌硎硒硜硞硠硡硣硤硨硪确硺硾碊碏碔碘碡碝碞碟
|
||||
碤碨碬碭碰碱碲碳碻碽碿磇磈磉磌磎磒磓磕磖磤磛磟磠磡磦磪磲磳礀
|
||||
磶磷磺磻磿礆礌礐礚礜礞礟礠礥礧礩礭礱礴礵礻礽礿祄祅祆祊祋祏祑
|
||||
祔祘祛祜祧祩祫祲祹祻祼祾禋禌禑禓禔禕禖禘禛禜禡禨禩禫禯禱禴禸
|
||||
离秂秄秇秈秊秏秔秖秚秝秞秠秢秥秪秫秭秱秸秼稂稃稇稉稊稌稑稕稛
|
||||
稞稡稧稫稭稯稰稴稵稸稹稺穄穅穇穈穌穕穖穙穜穝穟穠穥穧穪穭穵穸
|
||||
穾窀窂窅窆窊窋窐窑窔窞窠窣窬窳窵窹窻窼竆竉竌竎竑竛竨竩竫竬竱
|
||||
竴竻竽竾笇笔笟笣笧笩笪笫笭笮笯笰笱笴笽笿筀筁筇筎筕筠筤筦筩筪
|
||||
筭筯筲筳筷箄箉箎箐箑箖箛箞箠箥箬箯箰箲箵箶箺箻箼箽篂篅篈篊篔
|
||||
篖篗篙篚篛篨篪篲篴篵篸篹篺篼篾簁簂簃簄簆簉簋簌簎簏簙簛簠簥簦
|
||||
簨簬簱簳簴簶簹簺籆籊籕籑籒籓籙籚籛籜籝籞籡籣籧籩籭籮籰籲籹籼
|
||||
籽粆粇粏粔粞粠粦粰粶粷粺粻粼粿糄糇糈糉糍糏糓糔糕糗糙糚糝糦糩
|
||||
糫糵紃紇紈紉紏紑紒紓紖紝紞紣紦紪紭紱紼紽紾絀絁絇絈絍絑絓絗絙
|
||||
絚絜絝絥絧絪絰絸絺絻絿綁綂綃綅綆綈綋綌綍綑綖綗綝綞綦綧綪綳綶
|
||||
綷綹緂緃緄緅緆緌緍緎緗緙縀緢緥緦緪緫緭緱緵緶緹緺縈縐縑縕縗縜
|
||||
縝縠縧縨縬縭縯縳縶縿繄繅繇繎繐繒繘繟繡繢繥繫繮繯繳繸繾纁纆纇
|
||||
纊纍纑纕纘纚纝纞缼缻缽缾缿罃罄罇罏罒罓罛罜罝罡罣罤罥罦罭罱罽
|
||||
罾罿羀羋羍羏羐羑羖羗羜羡羢羦羪羭羴羼羿翀翃翈翎翏翛翟翣翥翨翬
|
||||
翮翯翲翺翽翾翿耇耈耊耍耎耏耑耓耔耖耝耞耟耠耤耦耬耮耰耴耵耷耹
|
||||
耺耼耾聀聄聠聤聦聭聱聵肁肈肎肜肞肦肧肫肸肹胈胍胏胒胔胕胗胘胠
|
||||
胭胮胰胲胳胶胹胺胾脃脋脖脗脘脜脞脠脤脧脬脰脵脺脼腅腇腊腌腒腗
|
||||
腠腡腧腨腩腭腯腷膁膐膄膅膆膋膎膖膘膛膞膢膮膲膴膻臋臃臅臊臎臏
|
||||
臕臗臛臝臞臡臤臫臬臰臱臲臵臶臸臹臽臿舀舃舏舓舔舙舚舝舡舢舨舲
|
||||
舴舺艃艄艅艆艋艎艏艑艖艜艠艣艧艭艴艻艽艿芀芁芃芄芇芉芊芎芑芔
|
||||
芖芘芚芛芠芡芣芤芧芨芩芪芮芰芲芴芷芺芼芾芿苆苐苕苚苠苢苤苨苪
|
||||
苭苯苶苷苽苾茀茁茇茈茊茋荔茛茝茞茟茡茢茬茭茮茰茳茷茺茼茽荂荃
|
||||
荄荇荍荎荑荕荖荗荰荸荽荿莀莂莄莆莍莒莔莕莘莙莛莜莝莦莧莩莬莾
|
||||
莿菀菇菉菏菐菑菔菝荓菨菪菶菸菹菼萁萆萊萏萑萕萙莭萯萹葅葇葈葊
|
||||
葍葏葑葒葖葘葙葚葜葠葤葥葧葪葰葳葴葶葸葼葽蒁蒅蒒蒓蒕蒞蒦蒨蒩
|
||||
蒪蒯蒱蒴蒺蒽蒾蓀蓂蓇蓈蓌蓏蓓蓜蓧蓪蓯蓰蓱蓲蓷蔲蓺蓻蓽蔂蔃蔇蔌
|
||||
蔎蔐蔜蔞蔢蔣蔤蔥蔧蔪蔫蔯蔳蔴蔶蔿蕆蕏蕐蕑蕒蕓蕖蕙蕜蕝蕞蕟蕠蕡
|
||||
蕢蕤蕫蕯蕹蕺蕻蕽蕿薁薅薆薉薋薌薏薓薘薝薟薠薢薥薧薴薶薷薸薼薽
|
||||
薾薿藂藇藊藋藎薭藘藚藟藠藦藨藭藳藶藼藿蘀蘄蘅蘍蘎蘐蘑蘒蘘蘙蘛
|
||||
蘞蘡蘧蘩蘶蘸蘺蘼蘽虀虂虆虒虓虖虗虘虙虝虠虡虢虣虤虩虬虯虵虶虷
|
||||
虺蚍蚑蚖蚘蚚蚜蚡蚦蚧蚨蚭蚱蚳蚴蚵蚷蚸蚹蚿蛀蛁蛃蛅蛑蛒蛕蛗蛚蛜
|
||||
蛠蛣蛥蛧蚈蛺蛼蛽蜄蜅蜇蜋蜎蜏蜐蜓蜔蜙蜞蜟蜡蜣蜨蜮蜯蜱蜲蜹蜺蜼
|
||||
蜽蜾蝀蝃蝅蝍蝘蝝蝡蝤蝥蝯蝱蝲蝻螃螄螅螆螇螈螉螋螌螐螓螕螗螘螙
|
||||
螞螠螣螧螬螭螮螱螵螾螿蟁蟈蟉蟊蟎蟕蟖蟙蟚蟜蟟蟢蟣蟤蟪蟫蟭蟱蟳
|
||||
蟸蟺蟿蠁蠃蠆蠉蠊蠋蠐蠙蠒蠓蠔蠘蠚蠛蠜蠞蠟蠨蠭蠮蠰蠲蠵蠺蠼衁衃
|
||||
衅衈衉衊衋衎衑衕衖衘衚衜衟衠衤衩衱衹衻袀袘袚袛袜袟袠袨袪袺袽
|
||||
袾裀裊裋裌裍裎裑裒裓裛裞裧裯裰裱裵裷褁褆褍褎褏褕褖褘褙褚褜褠
|
||||
褦褧褨褰褱褲褵褹褺褾襀襂襅襆襉襏襒襗襚襛襜襡襢襣襫襮襰襳襵襺
|
||||
襻襼襽覉覍覐覔覕覛覜覟覠覥覰覴覵覶覷覼觔觕觖觗觘觥觩觫觭觱觳
|
||||
觶觹觽觿訄訅訇訏訑訒訔訕訞訠訢訤訦訫訬訯訵訷訽訾詀詃詅詇詉詍
|
||||
詎詓詖詗詘詜詝詡詥詧詵詶詷詹詺詻詾詿誀誃誆誋誏誐誒誖誗誙誟誧
|
||||
誩誮誯誳誶誷誻誾諃諆諈諉諊諑諓諔諕諗諝諟諬諰諴諵諶諼諿謅謆謋
|
||||
謑謜謞謟謊謭謰謷謼譂譃譄譅譆譈譒譓譔譙譍譞譣譭譶譸譹譼譾讁讄
|
||||
讅讋讍讏讔讕讜讞讟谸谹谽谾豅豇豉豋豏豑豓豔豗豘豛豝豙豣豤豦豨
|
||||
豩豭豳豵豶豻豾貆貇貋貐貒貓貙貛貜貤貹貺賅賆賉賋賏賖賕賙賝賡賨
|
||||
賬賯賰賲賵賷賸賾賿贁贃贉贒贗贛赥赩赬赮赿趂趄趈趍趐趑趕趞趟趠
|
||||
趦趫趬趯趲趵趷趹趻跀跅跆跇跈跊跎跑跔跕跗跙跤跥跧跬跰趼跱跲跴
|
||||
跽踁踄踅踆踋踑踔踖踠踡踢踣踦踧踱踳踶踷踸踹踽蹀蹁蹋蹍蹎蹏蹔蹛
|
||||
蹜蹝蹞蹡蹢蹩蹬蹭蹯蹰蹱蹹蹺蹻躂躃躉躐躒躕躚躛躝躞躢躧躩躭躮躳
|
||||
躵躺躻軀軁軃軄軇軏軑軔軜軨軮軰軱軷軹軺軭輀輂輇輈輏輐輖輗輘輞
|
||||
輠輡輣輥輧輨輬輭輮輴輵輶輷輺轀轁轃轇轏轑轒轓轔轕轘轝轞轥辝辠
|
||||
辡辤辥辦辵辶辸达迀迁迆迊迋迍运迒迓迕迠迣迤迨迮迱迵迶迻迾适逄
|
||||
逈逌逘逛逨逩逯逪逬逭逳逴逷逿遃遄遌遛遝遢遦遧遬遰遴遹邅邈邋邌
|
||||
邎邐邕邗邘邙邛邠邡邢邥邰邲邳邴邶邽郌邾郃郄郅郇郈郕郗郘郙郜郝
|
||||
郟郥郒郶郫郯郰郴郾郿鄀鄄鄅鄆鄈鄍鄐鄔鄖鄗鄘鄚鄜鄞鄠鄥鄢鄣鄧鄩
|
||||
鄮鄯鄱鄴鄶鄷鄹鄺鄼鄽酃酇酈酏酓酗酙酚酛酡酤酧酭酴酹酺酻醁醃醅
|
||||
醆醊醎醑醓醔醕醘醞醡醦醨醬醭醮醰醱醲醳醶醻醼醽醿釂釃釅釓釔釗
|
||||
釙釚釞釤釥釩釪釬釭釮釯釰釱釷釹釻釽鈀鈁鈄鈅鈆鈇鈉鈊鈌鈐鈒鈓鈖
|
||||
鈘鈜鈝鈣鈤鈥鈦鈨鈮鈯鈰鈳鈵鈶鈸鈹鈺鈼鈾鉀鉂鉃鉆鉇鉊鉍鉎鉏鉑鉘
|
||||
鉙鉜鉝鉠鉡鉥鉧鉨鉩鉮鉯鉰鉵鉶鉷鉸鉹鉻鉼鉽鉿銈銉銊銍銎銒銗銙銟
|
||||
銠銤銥銧銨銫銯銲銶銸銺銻銼銽銿鋀鋁鋂鋃鋅鋆鋇鋈鋋鋌鋍鋎鋐鋓鋕
|
||||
鋗鋘鋙鋜鋝鋟鋠鋡鋣鋥鋧鋨鋬鋮鋰鋹鋻鋿錀錂錈錍錑錔錕錜錝錞錟錡
|
||||
錤錥錧錩錪錳錴錶錷鍇鍈鍉鍐鍑鍒鍕鍗鍘鍚鍞鍤鍥鍧鍩鍪鍭鍯鍰鍱鍳
|
||||
鍴鍶鍺鍽鍿鎀鎁鎂鎈鎊鎋鎍鎏鎒鎕鎘鎛鎞鎡鎣鎤鎦鎨鎫鎴鎵鎶鎺鎩鏁
|
||||
鏄鏅鏆鏇鏉鏊鏋鏌鏍鏓鏙鏜鏞鏟鏢鏦鏧鏹鏷鏸鏺鏻鏽鐁鐂鐄鐈鐉鐍鐎
|
||||
鐏鐕鐖鐗鐟鐮鐯鐱鐲鐳鐴鐻鐿鐽鑃鑅鑈鑊鑌鑕鑙鑜鑟鑡鑣鑨鑫鑭鑮鑯
|
||||
鑱鑲钄钃镸镹镾閄閈閌閍閎閝閞閟閡閦閩閫閬閴閶閺閽閿闆闈闉闋闐
|
||||
闑闒闓闙闚闝闞闟闠闤闦阝阞阢阤阥阦阬阱阳阷阸阹阺阼阽陁陒陔陖
|
||||
陗陘陡陮陴陻陼陾陿隁隂隃隄隉隑隖隚隝隟隤隥隦隩隮隯隳隺雊雒嶲
|
||||
雘雚雝雞雟雩雯雱雺霂霃霅霉霚霛霝霡霢霣霨霱霳靁靃靊靎靏靕靗靘
|
||||
靚靛靣靧靪靮靳靶靷靸靻靽靿鞀鞉鞕鞖鞗鞙鞚鞞鞟鞢鞬鞮鞱鞲鞵鞶鞸
|
||||
鞹鞺鞼鞾鞿韁韄韅韇韉韊韌韍韎韐韑韔韗韘韙韝韞韠韛韡韤韯韱韴韷
|
||||
韸韺頇頊頙頍頎頔頖頜頞頠頣頦頫頮頯頰頲頳頵頥頾顄顇顊顑顒顓顖
|
||||
顗顙顚顢顣顥顦顪顬颫颭颮颰颴颷颸颺颻颿飂飅飈飌飡飣飥飦飧飪飳
|
||||
飶餂餇餈餑餕餖餗餚餛餜餟餢餦餧餫餱餲餳餴餵餹餺餻餼饀饁饆饇饈
|
||||
饍饎饔饘饙饛饜饞饟饠馛馝馟馦馰馱馲馵馹馺馽馿駃駉駓駔駙駚駜駞
|
||||
駧駪駫駬駰駴駵駹駽駾騂騃騄騋騌騐騑騖騞騠騢騣騤騧騭騮騳騵騶騸
|
||||
驇驁驄驊驋驌驎驑驔驖驝骪骬骮骯骲骴骵骶骹骻骾骿髁髃髆髈髎髐髒
|
||||
髕髖髗髛髜髠髤髥髧髩髬髲髳髵髹髺髽髿鬀鬁鬂鬃鬄鬅鬈鬉鬋鬌鬍鬎
|
||||
鬐鬒鬖鬙鬛鬜鬠鬦鬫鬭鬳鬴鬵鬷鬹鬺鬽魈魋魌魕魖魗魛魞魡魣魥魦魨
|
||||
魪魫魬魭魮魳魵魷魸魹魿鮀鮄鮅鮆鮇鮉鮊鮋鮍鮏鮐鮔鮚鮝鮞鮦鮧鮩鮬
|
||||
鮰鮱鮲鮷鮸鮻鮼鮾鮿鯁鯇鯈鯎鯐鯗鯘鯝鯟鯥鯧鯪鯫鯯鯳鯷鯸鯹鯺鯽鯿
|
||||
鰀鰂鰋鰏鰑鰖鰘鰙鰚鰜鰞鰢鰣鰦鰧鰨鰩鰪鰱鰵鰶鰷鰽鱁鱃鱄鱅鱉鱊鱎
|
||||
鱏鱐鱓鱔鱖鱘鱛鱝鱞鱟鱣鱩鱪鱜鱫鱨鱮鱰鱲鱵鱷鱻鳦鳲鳷鳹鴋鴂鴑鴗
|
||||
鴘鴜鴝鴞鴯鴰鴲鴳鴴鴺鴼鵅鴽鵂鵃鵇鵊鵓鵔鵟鵣鵢鵥鵩鵪鵫鵰鵶鵷鵻
|
||||
鵼鵾鶃鶄鶆鶊鶍鶎鶒鶓鶕鶖鶗鶘鶡鶪鶬鶮鶱鶵鶹鶼鶿鷃鷇鷉鷊鷔鷕鷖
|
||||
鷗鷚鷞鷟鷠鷥鷧鷩鷫鷮鷰鷳鷴鷾鸊鸂鸇鸎鸐鸑鸒鸕鸖鸙鸜鸝鹺鹻鹼麀
|
||||
麂麃麄麅麇麎麏麖麘麛麞麤麨麬麮麯麰麳麴麵黆黈黋黕黟黤黧黬黭黮
|
||||
黰黱黲黵黸黿鼂鼃鼉鼏鼐鼑鼒鼔鼖鼗鼙鼚鼛鼟鼢鼦鼪鼫鼯鼱鼲鼴鼷鼹
|
||||
鼺鼼鼽鼿齁齃齄齅齆齇齓齕齖齗齘齚齝齞齨齩齭齮齯齰齱齳齵齺齽龏
|
||||
龐龑龒龔龖龗龞龡龢龣龥
|
||||
2
nodered/rootfs/data/node_modules/encoding-japanese/tests/surrogate-pairs-utf8.txt
generated
vendored
Normal file
2
nodered/rootfs/data/node_modules/encoding-japanese/tests/surrogate-pairs-utf8.txt
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
Surrogate Pairs Test
|
||||
𠮷野家で𩸽
|
||||
1395
nodered/rootfs/data/node_modules/encoding-japanese/tests/test.js
generated
vendored
Normal file
1395
nodered/rootfs/data/node_modules/encoding-japanese/tests/test.js
generated
vendored
Normal file
@@ -0,0 +1,1395 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var encoding = require('../encoding');
|
||||
|
||||
|
||||
describe('Encoding', function() {
|
||||
var encodings = ['SJIS', 'UTF-8', 'JIS', 'EUC-JP'];
|
||||
var urlEncoded = {
|
||||
SJIS: '%82%B1%82%CC%83e%83L%83X%83g%82%CD%20SJIS%20%82%C5%8F%91%82%A9%82%EA%82%C4%82%A2%82%DC%82%B7%81B',
|
||||
UTF8: '%E3%81%93%E3%81%AE%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%81%AF%20UTF-8%20%E3%81%A7%E6%9B%B8%E3%81%8B%E3%82%8C%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%80%82',
|
||||
JIS: '%1B%24B%243%24N%25F%25-%259%25H%24O%1B(B%20JIS%20%1B%24B%24G%3Dq%24%2B%24l%24F%24%24%24%5E%249!%23%1B(B',
|
||||
EUCJP: '%A4%B3%A4%CE%A5%C6%A5%AD%A5%B9%A5%C8%A4%CF%20EUC-JP%20%A4%C7%BD%F1%A4%AB%A4%EC%A4%C6%A4%A4%A4%DE%A4%B9%A1%A3'
|
||||
};
|
||||
|
||||
var getExpectedName = function(name) {
|
||||
return name.replace(/\W/g, '');
|
||||
};
|
||||
|
||||
var getExpectedText = function(name) {
|
||||
return '\u3053\u306e\u30c6\u30ad\u30b9\u30c8\u306f ' + name +
|
||||
' \u3067\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002';
|
||||
};
|
||||
|
||||
var getFileName = function(name) {
|
||||
return __dirname + '/encoding-' + getExpectedName(name).toLowerCase() + '.txt';
|
||||
};
|
||||
|
||||
var getCode = function(data) {
|
||||
var code = [];
|
||||
for (var i = 0, len = data.length; i < len; i++) {
|
||||
code.push(data[i]);
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
var buffers = {};
|
||||
var tests = {};
|
||||
|
||||
before(function() {
|
||||
tests.unicode = [];
|
||||
for (var i = 0; i <= 0xffff; i++) {
|
||||
tests.unicode.push(i);
|
||||
}
|
||||
tests.surrogatePairs = [0xD844, 0xDE7B];
|
||||
|
||||
var jisx0208 = fs.readFileSync(__dirname + '/jis-x-0208-utf8.txt');
|
||||
var jisx0208Len = jisx0208.length + 1;
|
||||
tests.jisx0208 = new Buffer(jisx0208Len);
|
||||
// Prepend an ascii character for UTF-16 detection.
|
||||
tests.jisx0208[0] = 'a'.charCodeAt(0);
|
||||
for (i = 1; i < jisx0208Len; i++) {
|
||||
tests.jisx0208[i] = jisx0208[i - 1];
|
||||
}
|
||||
assert.deepEqual(tests.jisx0208.slice(1), jisx0208);
|
||||
|
||||
tests.jisx0208Array = [];
|
||||
var len = tests.jisx0208.length;
|
||||
for (i = 0; i < len; i++) {
|
||||
tests.jisx0208Array.push(tests.jisx0208[i]);
|
||||
}
|
||||
tests.ascii = 'Hello World.';
|
||||
tests.surrogatePairs2 = fs.readFileSync(__dirname + '/surrogate-pairs-utf8.txt');
|
||||
|
||||
encodings.forEach(function(encodingName) {
|
||||
var data = fs.readFileSync(getFileName(encodingName));
|
||||
buffers[encodingName] = data;
|
||||
});
|
||||
});
|
||||
|
||||
describe('detect', function() {
|
||||
encodings.forEach(function(encodingName) {
|
||||
it(encodingName, function () {
|
||||
var res = encoding.detect(buffers[encodingName]);
|
||||
assert.equal(res, getExpectedName(encodingName));
|
||||
});
|
||||
});
|
||||
|
||||
it('UTF-16, UTF-16BE', function() {
|
||||
var utf16 = [
|
||||
0xFE,0xFF,0x30,0x53,0x30,0x6E,0x30,0xC6,0x30,0xAD,0x30,0xB9,0x30,
|
||||
0xC8,0x30,0x6F,0x00,0x20,0x00,0x55,0x00,0x54,0x00,0x46,0x00,0x2D,
|
||||
0x00,0x31,0x00,0x36,0x00,0x20,0x30,0x67,0x66,0xF8,0x30,0x4B,0x30,
|
||||
0x8C,0x30,0x66,0x30,0x44,0x30,0x7E,0x30,0x59,0x30,0x02
|
||||
];
|
||||
assert(encoding.detect(utf16, 'utf-16'));
|
||||
assert(encoding.detect(utf16) === 'UTF16');
|
||||
|
||||
var utf16_noBom = utf16.slice(2);
|
||||
assert(encoding.detect(utf16_noBom, 'utf-16'));
|
||||
assert(/^UTF16/.test(encoding.detect(utf16_noBom)));
|
||||
});
|
||||
|
||||
it('UTF-16LE', function() {
|
||||
var utf16le = [
|
||||
0x53,0x30,0x6E,0x30,0xC6,0x30,0xAD,0x30,0xB9,0x30,0xC8,0x30,0x6F,
|
||||
0x30,0x20,0x00,0x55,0x00,0x54,0x00,0x46,0x00,0x2D,0x00,0x31,0x00,
|
||||
0x36,0x00,0x4C,0x00,0x45,0x00,0x20,0x00,0x67,0x30,0xF8,0x66,0x4B,
|
||||
0x30,0x8C,0x30,0x66,0x30,0x44,0x30,0x7E,0x30,0x59,0x30,0x02,0x30
|
||||
];
|
||||
assert(encoding.detect(utf16le, 'utf-16'));
|
||||
assert(encoding.detect(utf16le) === 'UTF16');
|
||||
});
|
||||
|
||||
it('UTF-32, UTF-32BE', function() {
|
||||
var utf32 = [
|
||||
0x00,0x00,0xFE,0xFF,0x00,0x00,0x30,0x53,0x00,0x00,0x30,0x6E,0x00,
|
||||
0x00,0x30,0xC6,0x00,0x00,0x30,0xAD,0x00,0x00,0x30,0xB9,0x00,0x00,
|
||||
0x30,0xC8,0x00,0x00,0x30,0x6F,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
|
||||
0x55,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0x46,0x00,0x00,0x00,0x2D,
|
||||
0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x20,0x00,
|
||||
0x00,0x30,0x67,0x00,0x00,0x66,0xF8,0x00,0x00,0x30,0x4B,0x00,0x00,
|
||||
0x30,0x8C,0x00,0x00,0x30,0x66,0x00,0x00,0x30,0x44,0x00,0x00,0x30,
|
||||
0x7E,0x00,0x00,0x30,0x59,0x00,0x00,0x30,0x02
|
||||
];
|
||||
assert(encoding.detect(utf32, 'utf-32'));
|
||||
assert(encoding.detect(utf32) === 'UTF32');
|
||||
|
||||
var utf32_noBom = utf32.slice(4);
|
||||
assert(encoding.detect(utf32_noBom, 'utf-32'));
|
||||
assert(/^UTF32/.test(encoding.detect(utf32_noBom)));
|
||||
});
|
||||
|
||||
it('UTF-32LE', function() {
|
||||
var utf32le = [
|
||||
0x53,0x30,0x00,0x00,0x6E,0x30,0x00,0x00,0xC6,0x30,0x00,0x00,0xAD,
|
||||
0x30,0x00,0x00,0xB9,0x30,0x00,0x00,0xC8,0x30,0x00,0x00,0x6F,0x30,
|
||||
0x00,0x00,0x20,0x00,0x00,0x00,0x55,0x00,0x00,0x00,0x54,0x00,0x00,
|
||||
0x00,0x46,0x00,0x00,0x00,0x2D,0x00,0x00,0x00,0x33,0x00,0x00,0x00,
|
||||
0x32,0x00,0x00,0x00,0x4C,0x00,0x00,0x00,0x45,0x00,0x00,0x00,0x20,
|
||||
0x00,0x00,0x00,0x67,0x30,0x00,0x00,0xF8,0x66,0x00,0x00,0x4B,0x30,
|
||||
0x00,0x00,0x8C,0x30,0x00,0x00,0x66,0x30,0x00,0x00,0x44,0x30,0x00,
|
||||
0x00,0x7E,0x30,0x00,0x00,0x59,0x30,0x00,0x00,0x02,0x30,0x00,0x00
|
||||
];
|
||||
assert(encoding.detect(utf32le, 'utf-32'));
|
||||
assert(encoding.detect(utf32le) === 'UTF32');
|
||||
});
|
||||
|
||||
it('Specifying multiple encodings', function() {
|
||||
var unicode = 'ユニコード';
|
||||
|
||||
assert.equal(encoding.detect(unicode, 'UNICODE'), 'UNICODE');
|
||||
assert.equal(encoding.detect(unicode, ['UNICODE']), 'UNICODE');
|
||||
assert.equal(encoding.detect(unicode, {encoding: 'UNICODE'}), 'UNICODE');
|
||||
assert.equal(encoding.detect(unicode, {encoding: ['UNICODE']}), 'UNICODE');
|
||||
assert.equal(encoding.detect(unicode, []), false);
|
||||
assert.equal(encoding.detect(unicode, ['UNICODE', 'ASCII']), 'UNICODE');
|
||||
assert.equal(encoding.detect(unicode, 'ASCII, EUCJP, UNICODE'), 'UNICODE');
|
||||
assert.equal(encoding.detect(unicode, ['SJIS', 'UTF8', 'ASCII']), false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('convert', function() {
|
||||
encodings.forEach(function(encodingName) {
|
||||
it(encodingName, function () {
|
||||
var res = encoding.codeToString(
|
||||
encoding.convert(buffers[encodingName], 'unicode', encodingName));
|
||||
assert.equal(res, getExpectedText(encodingName));
|
||||
});
|
||||
});
|
||||
|
||||
it('ASCII', function() {
|
||||
assert(tests.ascii.length > 0);
|
||||
var encoded = encoding.convert(tests.ascii, 'sjis', 'auto');
|
||||
assert(encoded.length > 0);
|
||||
var decoded = encoding.convert(encoded, 'unicode', 'auto');
|
||||
assert(decoded.length > 0);
|
||||
assert.deepEqual(decoded, tests.ascii);
|
||||
});
|
||||
|
||||
it('Unicode/UTF-8', function() {
|
||||
assert(tests.unicode.length === 65536);
|
||||
var utf8 = encoding.convert(tests.unicode, 'utf-8', 'unicode');
|
||||
assert(utf8.length > 0);
|
||||
assert.notDeepEqual(utf8, tests.unicode);
|
||||
var unicode = encoding.convert(utf8, 'unicode', 'utf-8');
|
||||
assert(unicode.length === 65536);
|
||||
assert.deepEqual(unicode, tests.unicode);
|
||||
});
|
||||
|
||||
it('Object arguments', function() {
|
||||
var text = getExpectedText(getExpectedName('UTF-8'));
|
||||
var data = encoding.stringToCode(text);
|
||||
assert(data.length > 0);
|
||||
assert(encoding.detect(data, 'UNICODE'));
|
||||
|
||||
var utf8 = encoding.convert(data, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode'
|
||||
});
|
||||
assert(utf8.length > 0);
|
||||
assert.notDeepEqual(utf8, data);
|
||||
assert(encoding.detect(utf8, 'utf-8'));
|
||||
|
||||
var unicode = encoding.convert(utf8, {
|
||||
to: 'unicode',
|
||||
from: 'utf-8'
|
||||
});
|
||||
assert(unicode.length > 0);
|
||||
assert.deepEqual(unicode, data);
|
||||
assert(encoding.detect(unicode, 'unicode'));
|
||||
});
|
||||
|
||||
it('Surrogate pairs', function() {
|
||||
assert(tests.surrogatePairs.length >= 2);
|
||||
var utf8 = encoding.convert(tests.surrogatePairs, 'utf-8', 'unicode');
|
||||
assert(utf8.length > 0);
|
||||
assert.notDeepEqual(utf8, tests.surrogatePairs);
|
||||
var unicode = encoding.convert(utf8, 'unicode', 'utf-8');
|
||||
assert(unicode.length >= 2);
|
||||
assert.deepEqual(unicode, tests.surrogatePairs);
|
||||
});
|
||||
|
||||
it('Surrogate pairs and UTF-8 conversion', function() {
|
||||
var surrogatePairs = [
|
||||
83,117,114,114,111,103,97,116,101,32,80,97,105,114,115,32,84,
|
||||
101,115,116,10,55362,57271,37326,23478,12391,55399,56893,10
|
||||
];
|
||||
var surrogatePairs_utf8 = [
|
||||
0x53, 0x75, 0x72, 0x72, 0x6F, 0x67, 0x61, 0x74, 0x65, 0x20,
|
||||
0x50, 0x61, 0x69, 0x72, 0x73, 0x20, 0x54, 0x65, 0x73, 0x74,
|
||||
0x0A, 0xF0, 0xA0, 0xAE, 0xB7, 0xE9, 0x87, 0x8E, 0xE5, 0xAE,
|
||||
0xB6, 0xE3, 0x81, 0xA7, 0xF0, 0xA9, 0xB8, 0xBD, 0x0A
|
||||
];
|
||||
var utf8 = encoding.convert(surrogatePairs, 'utf-8', 'unicode');
|
||||
assert(utf8.length > 0);
|
||||
assert.notDeepEqual(utf8, surrogatePairs);
|
||||
assert.deepEqual(utf8, surrogatePairs_utf8);
|
||||
|
||||
var unicode = encoding.convert(utf8, 'unicode', 'utf-8');
|
||||
assert(unicode.length > 0);
|
||||
assert.notDeepEqual(unicode, utf8);
|
||||
assert.deepEqual(unicode, surrogatePairs);
|
||||
});
|
||||
|
||||
it('Surrogate pairs and UTF-16 conversion', function() {
|
||||
var surrogatePairs = [];
|
||||
for (var i = 0; i < tests.surrogatePairs2.length; i++) {
|
||||
surrogatePairs.push(tests.surrogatePairs2[i]);
|
||||
}
|
||||
assert(surrogatePairs.length >= 2);
|
||||
var utf8 = encoding.convert(surrogatePairs, 'utf-8', 'unicode');
|
||||
assert(utf8.length > 0);
|
||||
assert.notDeepEqual(utf8, surrogatePairs);
|
||||
var unicode = encoding.convert(utf8, 'unicode', 'utf-8');
|
||||
assert(unicode.length >= 2);
|
||||
assert.deepEqual(unicode, surrogatePairs);
|
||||
|
||||
var utf16 = encoding.convert(utf8, 'utf-16', 'utf-8');
|
||||
assert(utf16.length > 0);
|
||||
assert.notDeepEqual(utf16, utf8);
|
||||
var isUTF16 = encoding.detect(utf16, 'utf-16');
|
||||
assert(isUTF16);
|
||||
var c1 = utf16[0];
|
||||
var c2 = utf16[1];
|
||||
// Check BOM
|
||||
assert(!((c1 === 0xFE && c2 === 0xFF) && (c1 === 0xFF && c2 === 0xFE)));
|
||||
var newUTF8 = encoding.convert(utf16, 'utf-8', 'utf-16');
|
||||
assert.deepEqual(utf8, newUTF8);
|
||||
var newUnicode = encoding.convert(utf16, 'unicode', 'utf-16');
|
||||
assert.deepEqual(newUnicode, unicode);
|
||||
});
|
||||
|
||||
it('UTF-16 with BOM conversion', function() {
|
||||
var data = [];
|
||||
for (var i = 0; i < tests.surrogatePairs2.length; i++) {
|
||||
data.push(tests.surrogatePairs2[i]);
|
||||
}
|
||||
assert(data.length > 0);
|
||||
var utf8 = encoding.convert(data, 'utf-8', 'unicode');
|
||||
assert(utf8.length > 0);
|
||||
assert.notDeepEqual(utf8, data);
|
||||
var unicode = encoding.convert(utf8, 'unicode', 'utf-8');
|
||||
assert(unicode.length > 0);
|
||||
assert.deepEqual(unicode, data);
|
||||
|
||||
// UTF-16 without BOM
|
||||
var utf16_noBom = encoding.convert(utf8, 'utf-16', 'utf-8');
|
||||
assert(utf16_noBom.length > 0);
|
||||
assert.notDeepEqual(utf16_noBom, utf8);
|
||||
|
||||
var c1 = utf16_noBom[0];
|
||||
var c2 = utf16_noBom[1];
|
||||
// Check BOM
|
||||
assert(!((c1 === 0xFE && c2 === 0xFF) && (c1 === 0xFF && c2 === 0xFE)));
|
||||
|
||||
// Test detect
|
||||
var isUTF16 = encoding.detect(utf16_noBom, 'utf-16');
|
||||
assert(isUTF16);
|
||||
var isUTF16BE = encoding.detect(utf16_noBom, 'utf-16be');
|
||||
assert(isUTF16BE);
|
||||
var isUTF16LE = encoding.detect(utf16_noBom, 'utf-16le');
|
||||
assert(!isUTF16LE);
|
||||
|
||||
// UTF-16 with BOM (BE)
|
||||
var utf16_bom_true = encoding.convert(utf8, {
|
||||
to: 'utf-16',
|
||||
from: 'utf-8',
|
||||
bom: true
|
||||
});
|
||||
|
||||
c1 = utf16_bom_true[0];
|
||||
c2 = utf16_bom_true[1];
|
||||
// Check BOM
|
||||
assert(c1 === 0xFE && c2 === 0xFF);
|
||||
|
||||
// Test detect
|
||||
isUTF16 = encoding.detect(utf16_bom_true, 'utf-16');
|
||||
assert(isUTF16);
|
||||
isUTF16BE = encoding.detect(utf16_bom_true, 'utf-16be');
|
||||
assert(isUTF16BE);
|
||||
isUTF16LE = encoding.detect(utf16_bom_true, 'utf-16le');
|
||||
assert(!isUTF16LE);
|
||||
|
||||
// Check other argument specified
|
||||
var utf16_bom_be = encoding.convert(utf8, {
|
||||
to: 'utf-16',
|
||||
from: 'utf-8',
|
||||
bom: 'be'
|
||||
});
|
||||
assert.deepEqual(utf16_bom_true, utf16_bom_be);
|
||||
|
||||
var newUTF8 = encoding.convert(utf16_bom_be, 'utf-8', 'utf-16');
|
||||
assert.deepEqual(utf8, newUTF8);
|
||||
var newUnicode = encoding.convert(utf16_bom_be, 'unicode', 'utf-16');
|
||||
assert.deepEqual(newUnicode, unicode);
|
||||
|
||||
// UTF-16 with BOM (LE)
|
||||
var utf16_bom_le = encoding.convert(utf8, {
|
||||
to: 'utf-16',
|
||||
from: 'utf-8',
|
||||
bom: 'le'
|
||||
});
|
||||
|
||||
c1 = utf16_bom_le[0];
|
||||
c2 = utf16_bom_le[1];
|
||||
// Check BOM
|
||||
assert(c1 === 0xFF && c2 === 0xFE);
|
||||
|
||||
// Test detect
|
||||
isUTF16 = encoding.detect(utf16_bom_le, 'utf-16');
|
||||
assert(isUTF16);
|
||||
isUTF16BE = encoding.detect(utf16_bom_le, 'utf-16be');
|
||||
assert(!isUTF16BE);
|
||||
isUTF16LE = encoding.detect(utf16_bom_le, 'utf-16le');
|
||||
assert(isUTF16LE);
|
||||
|
||||
newUTF8 = encoding.convert(utf16_bom_le, 'utf-8', 'utf-16');
|
||||
assert.deepEqual(utf8, newUTF8);
|
||||
newUnicode = encoding.convert(utf16_bom_le, 'unicode', 'utf-16');
|
||||
assert.deepEqual(newUnicode, unicode);
|
||||
});
|
||||
|
||||
it('UTF-16BE conversion', function() {
|
||||
var data = [];
|
||||
for (var i = 0; i < tests.surrogatePairs2.length; i++) {
|
||||
data.push(tests.surrogatePairs2[i]);
|
||||
}
|
||||
assert(data.length > 0);
|
||||
var utf8 = encoding.convert(data, 'utf-8', 'unicode');
|
||||
assert(utf8.length > 0);
|
||||
assert.notDeepEqual(utf8, data);
|
||||
var unicode = encoding.convert(utf8, 'unicode', 'utf-8');
|
||||
assert(unicode.length > 0);
|
||||
assert.deepEqual(unicode, data);
|
||||
|
||||
var utf16be = encoding.convert(utf8, 'utf-16be', 'utf-8');
|
||||
assert(utf16be.length > 0);
|
||||
assert.notDeepEqual(utf16be, utf8);
|
||||
|
||||
var isUTF16BE = encoding.detect(utf16be, 'utf-16be');
|
||||
assert(isUTF16BE);
|
||||
var isUTF16 = encoding.detect(utf16be, 'utf-16');
|
||||
assert(isUTF16);
|
||||
var isUTF16LE = encoding.detect(utf16be, 'utf-16le');
|
||||
assert(!isUTF16LE);
|
||||
|
||||
var c1 = utf16be[0];
|
||||
var c2 = utf16be[1];
|
||||
// Check BOM
|
||||
assert(!((c1 === 0xFE && c2 === 0xFF) && (c1 === 0xFF && c2 === 0xFE)));
|
||||
var newUTF8 = encoding.convert(utf16be, 'utf-8', 'utf-16be');
|
||||
assert.deepEqual(utf8, newUTF8);
|
||||
var newUnicode = encoding.convert(utf16be, 'unicode', 'utf-16be');
|
||||
assert.deepEqual(newUnicode, unicode);
|
||||
});
|
||||
|
||||
it('UTF-16LE conversion', function() {
|
||||
var data = [];
|
||||
for (var i = 0; i < tests.surrogatePairs2.length; i++) {
|
||||
data.push(tests.surrogatePairs2[i]);
|
||||
}
|
||||
assert(data.length > 0);
|
||||
var utf8 = encoding.convert(data, 'utf-8', 'unicode');
|
||||
assert(utf8.length > 0);
|
||||
assert.notDeepEqual(utf8, data);
|
||||
var unicode = encoding.convert(utf8, 'unicode', 'utf-8');
|
||||
assert(unicode.length > 0);
|
||||
assert.deepEqual(unicode, data);
|
||||
|
||||
var utf16le = encoding.convert(utf8, 'utf-16le', 'utf-8');
|
||||
assert(utf16le.length > 0);
|
||||
assert.notDeepEqual(utf16le, utf8);
|
||||
|
||||
var isUTF16LE = encoding.detect(utf16le, 'utf-16le');
|
||||
assert(isUTF16LE);
|
||||
var isUTF16 = encoding.detect(utf16le, 'utf-16');
|
||||
assert(isUTF16);
|
||||
var isUTF16BE = encoding.detect(utf16le, 'utf-16be');
|
||||
assert(!isUTF16BE);
|
||||
|
||||
var c1 = utf16le[0];
|
||||
var c2 = utf16le[1];
|
||||
// Check BOM
|
||||
assert(!((c1 === 0xFE && c2 === 0xFF) && (c1 === 0xFF && c2 === 0xFE)));
|
||||
var newUTF8 = encoding.convert(utf16le, 'utf-8', 'utf-16le');
|
||||
assert.deepEqual(utf8, newUTF8);
|
||||
var newUnicode = encoding.convert(utf16le, 'unicode', 'utf-16le');
|
||||
assert.deepEqual(newUnicode, unicode);
|
||||
});
|
||||
|
||||
it('Halfwidth Katakana conversion', function() {
|
||||
var hankana = '。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚';
|
||||
var hankanas = encoding.stringToCode(hankana);
|
||||
assert(hankanas.length > 0);
|
||||
assert(encoding.detect(hankanas) === 'UNICODE');
|
||||
|
||||
var sjis_expect = [
|
||||
0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,
|
||||
0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,
|
||||
0xBB,0xBC,0xBD,0xBE,0xBF,0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,
|
||||
0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,
|
||||
0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF
|
||||
];
|
||||
|
||||
var sjis = encoding.convert(hankanas, 'SJIS', 'UNICODE');
|
||||
assert(encoding.detect(sjis) === 'SJIS');
|
||||
assert.deepEqual(sjis, sjis_expect);
|
||||
|
||||
var jis_expect = [
|
||||
0x1B,0x28,0x49,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,
|
||||
0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,
|
||||
0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,0x41,0x42,0x43,0x44,
|
||||
0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50,0x51,
|
||||
0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,
|
||||
0x5F,0x1B,0x28,0x42
|
||||
];
|
||||
var jis = encoding.convert(hankanas, 'jis', 'unicode');
|
||||
assert(encoding.detect(jis) === 'JIS');
|
||||
assert.deepEqual(jis, jis_expect);
|
||||
|
||||
var eucjp_expect = [
|
||||
0x8E,0xA1,0x8E,0xA2,0x8E,0xA3,0x8E,0xA4,0x8E,0xA5,0x8E,0xA6,0x8E,
|
||||
0xA7,0x8E,0xA8,0x8E,0xA9,0x8E,0xAA,0x8E,0xAB,0x8E,0xAC,0x8E,0xAD,
|
||||
0x8E,0xAE,0x8E,0xAF,0x8E,0xB0,0x8E,0xB1,0x8E,0xB2,0x8E,0xB3,0x8E,
|
||||
0xB4,0x8E,0xB5,0x8E,0xB6,0x8E,0xB7,0x8E,0xB8,0x8E,0xB9,0x8E,0xBA,
|
||||
0x8E,0xBB,0x8E,0xBC,0x8E,0xBD,0x8E,0xBE,0x8E,0xBF,0x8E,0xC0,0x8E,
|
||||
0xC1,0x8E,0xC2,0x8E,0xC3,0x8E,0xC4,0x8E,0xC5,0x8E,0xC6,0x8E,0xC7,
|
||||
0x8E,0xC8,0x8E,0xC9,0x8E,0xCA,0x8E,0xCB,0x8E,0xCC,0x8E,0xCD,0x8E,
|
||||
0xCE,0x8E,0xCF,0x8E,0xD0,0x8E,0xD1,0x8E,0xD2,0x8E,0xD3,0x8E,0xD4,
|
||||
0x8E,0xD5,0x8E,0xD6,0x8E,0xD7,0x8E,0xD8,0x8E,0xD9,0x8E,0xDA,0x8E,
|
||||
0xDB,0x8E,0xDC,0x8E,0xDD,0x8E,0xDE,0x8E,0xDF
|
||||
];
|
||||
|
||||
var eucjp = encoding.convert(hankanas, 'eucjp', 'unicode');
|
||||
assert(encoding.detect(eucjp) === 'EUCJP');
|
||||
assert.deepEqual(eucjp, eucjp_expect);
|
||||
});
|
||||
|
||||
it('JIS special table conversion', function() {
|
||||
//NOTE: This characters is not completed for mojibake.
|
||||
var chars = [
|
||||
0x0030,0x0020,0x007E,0x0020,0x005C,0x0020,0xFFE5,0x0020,0xFF5E,
|
||||
0x0020,0xFFE3,0x0020,0xFF02,0x0020,0x2015,0x0020,0xFFE0,0x0020,
|
||||
0xFFE1,0x0020,0xFFE2,0x0020,0xFFE4,0x0020,0xFF07,0x0020,0x2225,
|
||||
0x0020,0x005C,0x0020,0x002F,0x0020,0xFF3C,0x0020,0x0020,0x2116,
|
||||
0x0020,0x3231,0x0020,0x334D,0x0020,0x0061,0x0020,0x3042,0x0020,
|
||||
0x3087,0x0020,0xFF71,0x0020,0x30A2,0x0020,0x30A1,0x0020,0x7533,
|
||||
0x0020,0x80FD,0x0020,0x5F0C,0x0020,0x4E9C,0x0020,0x7E3A,0x0020,
|
||||
0x7E67,0x0020,0x4EAB,0x0020,0x7E8A,0x0020,0x8868,0x0020,0x2460,
|
||||
0x0020,0x2170,0x0020,0x2164
|
||||
];
|
||||
|
||||
['JIS', 'SJIS', 'EUCJP', 'UTF8'].forEach(function(encodingName) {
|
||||
var encoded = encoding.convert(chars, {
|
||||
to: encodingName,
|
||||
from: 'auto'
|
||||
});
|
||||
assert(encoding.detect(encoded) === encodingName);
|
||||
assert(encoded.length > 0);
|
||||
|
||||
var decoded = encoding.convert(encoded, {
|
||||
to: 'unicode',
|
||||
from: 'auto'
|
||||
});
|
||||
assert.deepEqual(decoded, chars);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('convert JIS-X-0208', function() {
|
||||
var encodingNames = [
|
||||
'UTF16', 'UTF16BE', 'UTF16LE', 'SJIS', 'EUCJP', 'JIS', 'UNICODE'
|
||||
];
|
||||
encodingNames.forEach(function(encodingName) {
|
||||
it('UTF8 to ' + encodingName, function() {
|
||||
assert(tests.jisx0208.length > 0);
|
||||
assert(encoding.detect(tests.jisx0208, 'utf-8'));
|
||||
assert(encoding.detect(tests.jisx0208) === 'UTF8');
|
||||
var encoded = encoding.convert(tests.jisx0208, {
|
||||
to: encodingName,
|
||||
from: 'utf-8'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, encodingName));
|
||||
|
||||
var detected = encoding.detect(encoded);
|
||||
if (/^UTF16/.test(encodingName)) {
|
||||
assert(/^UTF16/.test(detected));
|
||||
} else {
|
||||
assert(detected === encodingName);
|
||||
}
|
||||
|
||||
var decoded = encoding.convert(encoded, {
|
||||
to: 'utf-8',
|
||||
from: encodingName
|
||||
});
|
||||
assert.deepEqual(decoded, tests.jisx0208Array);
|
||||
});
|
||||
});
|
||||
|
||||
it('UTF-8 to Unicode', function() {
|
||||
var encoded = encoding.convert(tests.jisx0208, {
|
||||
to: 'unicode',
|
||||
from: 'utf-8'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, 'unicode'));
|
||||
assert(encoding.detect(encoded) === 'UNICODE');
|
||||
tests.jisx0208_unicode = encoded;
|
||||
});
|
||||
|
||||
encodingNames = [
|
||||
'UTF16', 'UTF16BE', 'UTF16LE', 'SJIS', 'EUCJP', 'JIS', 'UTF8'
|
||||
];
|
||||
encodingNames.forEach(function(encodingName) {
|
||||
it('UNICODE to ' + encodingName, function() {
|
||||
assert(tests.jisx0208_unicode.length > 0);
|
||||
assert(encoding.detect(tests.jisx0208_unicode, 'unicode'));
|
||||
assert(encoding.detect(tests.jisx0208_unicode) === 'UNICODE');
|
||||
var encoded = encoding.convert(tests.jisx0208_unicode, {
|
||||
to: encodingName,
|
||||
from: 'unicode'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, encodingName));
|
||||
|
||||
var detected = encoding.detect(encoded);
|
||||
if (/^UTF16/.test(encodingName)) {
|
||||
assert(/^UTF16/.test(detected));
|
||||
} else {
|
||||
assert(detected === encodingName);
|
||||
}
|
||||
|
||||
var decoded = encoding.convert(encoded, {
|
||||
to: 'unicode',
|
||||
from: encodingName
|
||||
});
|
||||
assert.deepEqual(decoded, tests.jisx0208_unicode);
|
||||
});
|
||||
});
|
||||
|
||||
it('Unicode to Shift_JIS', function() {
|
||||
var encoded = encoding.convert(tests.jisx0208, {
|
||||
to: 'sjis',
|
||||
from: 'utf-8'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, 'sjis'));
|
||||
assert(encoding.detect(encoded) === 'SJIS');
|
||||
tests.jisx0208_sjis = encoded;
|
||||
});
|
||||
|
||||
encodingNames = [
|
||||
'UTF16', 'UTF16BE', 'UTF16LE', 'UNICODE', 'EUCJP', 'JIS', 'UTF8'
|
||||
];
|
||||
encodingNames.forEach(function(encodingName) {
|
||||
it('SJIS to ' + encodingName, function() {
|
||||
assert(tests.jisx0208_sjis.length > 0);
|
||||
assert(encoding.detect(tests.jisx0208_sjis, 'sjis'));
|
||||
assert(encoding.detect(tests.jisx0208_sjis) === 'SJIS');
|
||||
var encoded = encoding.convert(tests.jisx0208_sjis, {
|
||||
to: encodingName,
|
||||
from: 'sjis'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, encodingName));
|
||||
|
||||
var detected = encoding.detect(encoded);
|
||||
if (/^UTF16/.test(encodingName)) {
|
||||
assert(/^UTF16/.test(detected));
|
||||
} else {
|
||||
assert(detected === encodingName);
|
||||
}
|
||||
|
||||
var decoded = encoding.convert(encoded, {
|
||||
to: 'sjis',
|
||||
from: encodingName
|
||||
});
|
||||
assert.deepEqual(decoded, tests.jisx0208_sjis);
|
||||
});
|
||||
});
|
||||
|
||||
it('Shift_JIS to EUC-JP', function() {
|
||||
var encoded = encoding.convert(tests.jisx0208, {
|
||||
to: 'eucjp',
|
||||
from: 'utf-8'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, 'eucjp'));
|
||||
assert(encoding.detect(encoded) === 'EUCJP');
|
||||
tests.jisx0208_eucjp = encoded;
|
||||
});
|
||||
|
||||
encodingNames = [
|
||||
'UTF16', 'UTF16BE', 'UTF16LE', 'UNICODE', 'SJIS', 'JIS', 'UTF8'
|
||||
];
|
||||
encodingNames.forEach(function(encodingName) {
|
||||
it('EUCJP to ' + encodingName, function() {
|
||||
assert(tests.jisx0208_eucjp.length > 0);
|
||||
assert(encoding.detect(tests.jisx0208_eucjp, 'eucjp'));
|
||||
assert(encoding.detect(tests.jisx0208_eucjp) === 'EUCJP');
|
||||
var encoded = encoding.convert(tests.jisx0208_eucjp, {
|
||||
to: encodingName,
|
||||
from: 'eucjp'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, encodingName));
|
||||
|
||||
var detected = encoding.detect(encoded);
|
||||
if (/^UTF16/.test(encodingName)) {
|
||||
assert(/^UTF16/.test(detected));
|
||||
} else {
|
||||
assert(detected === encodingName);
|
||||
}
|
||||
|
||||
var decoded = encoding.convert(encoded, {
|
||||
to: 'eucjp',
|
||||
from: encodingName
|
||||
});
|
||||
assert.deepEqual(decoded, tests.jisx0208_eucjp);
|
||||
});
|
||||
});
|
||||
|
||||
it('EUC-JP to JIS', function() {
|
||||
var encoded = encoding.convert(tests.jisx0208, {
|
||||
to: 'jis',
|
||||
from: 'utf-8'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, 'jis'));
|
||||
assert(encoding.detect(encoded) === 'JIS');
|
||||
tests.jisx0208_jis = encoded;
|
||||
});
|
||||
|
||||
encodingNames = [
|
||||
'UTF16', 'UTF16BE', 'UTF16LE', 'UNICODE', 'SJIS', 'EUCJP', 'UTF8'
|
||||
];
|
||||
encodingNames.forEach(function(encodingName) {
|
||||
it('JIS to ' + encodingName, function() {
|
||||
assert(tests.jisx0208_jis.length > 0);
|
||||
assert(encoding.detect(tests.jisx0208_jis, 'jis'));
|
||||
assert(encoding.detect(tests.jisx0208_jis) === 'JIS');
|
||||
var encoded = encoding.convert(tests.jisx0208_jis, {
|
||||
to: encodingName,
|
||||
from: 'jis'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, encodingName));
|
||||
|
||||
var detected = encoding.detect(encoded);
|
||||
if (/^UTF16/.test(encodingName)) {
|
||||
assert(/^UTF16/.test(detected));
|
||||
} else {
|
||||
assert(detected === encodingName);
|
||||
}
|
||||
|
||||
var decoded = encoding.convert(encoded, {
|
||||
to: 'jis',
|
||||
from: encodingName
|
||||
});
|
||||
assert.deepEqual(decoded, tests.jisx0208_jis);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('convert JIS-X-0212', function() {
|
||||
var jisx0212_buffer = fs.readFileSync(__dirname + '/jis-x-0212-utf8.txt');
|
||||
var jisx0212_array = [];
|
||||
for (var i = 0, len = jisx0212_buffer.length; i < len; i++) {
|
||||
jisx0212_array.push(jisx0212_buffer[i]);
|
||||
}
|
||||
|
||||
var jisx0212_sjis_buffer = fs.readFileSync(__dirname + '/jis-x-0212-sjis-to-utf8.txt');
|
||||
var jisx0212_sjis_array = [];
|
||||
for (var i = 0, len = jisx0212_sjis_buffer.length; i < len; i++) {
|
||||
jisx0212_sjis_array.push(jisx0212_sjis_buffer[i]);
|
||||
}
|
||||
|
||||
it('UTF-8 to Unicode', function() {
|
||||
var encoded = encoding.convert(jisx0212_buffer, {
|
||||
to: 'unicode',
|
||||
from: 'utf-8'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, 'unicode'));
|
||||
assert(encoding.detect(encoded) === 'UNICODE');
|
||||
});
|
||||
|
||||
it('UTF-8 to SJIS / SJIS to UTF-8', function() {
|
||||
var encoded = encoding.convert(jisx0212_buffer, {
|
||||
to: 'sjis',
|
||||
from: 'utf-8'
|
||||
});
|
||||
assert(encoded.length > 0);
|
||||
assert(encoding.detect(encoded, 'sjis'));
|
||||
assert(encoding.detect(encoded) === 'SJIS');
|
||||
var encoded_sjis_to_utf8 = encoding.convert(encoded, {
|
||||
to: 'utf-8',
|
||||
from: 'sjis'
|
||||
});
|
||||
assert.deepEqual(encoded_sjis_to_utf8, jisx0212_sjis_array);
|
||||
});
|
||||
|
||||
var encodingNames = [
|
||||
'UTF16', 'UTF16BE', 'UTF16LE', 'UNICODE', 'JIS', 'EUCJP', 'UTF8'
|
||||
];
|
||||
|
||||
encodingNames.forEach(function(encodingName1) {
|
||||
var encoded1 = encoding.convert(jisx0212_array, {
|
||||
to: encodingName1,
|
||||
from: 'utf-8'
|
||||
});
|
||||
var detected = encoding.detect(encoded1);
|
||||
if (/^UTF16/.test(encodingName1)) {
|
||||
assert(/^UTF16/.test(detected));
|
||||
} else {
|
||||
assert(detected === encodingName1);
|
||||
}
|
||||
|
||||
encodingNames.forEach(function(encodingName2) {
|
||||
it(encodingName1 + ' to ' + encodingName2, function() {
|
||||
var encoded2 = encoding.convert(encoded1, {
|
||||
to: encodingName2,
|
||||
from: encodingName1
|
||||
});
|
||||
assert(encoded2.length > 0);
|
||||
|
||||
var detected2 = encoding.detect(encoded2);
|
||||
if (/^UTF16/.test(encodingName2)) {
|
||||
assert(/^UTF16/.test(detected2));
|
||||
} else {
|
||||
assert(detected2 === encodingName2);
|
||||
}
|
||||
|
||||
var decoded = encoding.convert(encoded2, {
|
||||
to: 'utf-8',
|
||||
from: encodingName2
|
||||
});
|
||||
assert.deepEqual(decoded, jisx0212_array);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('urlEncode/urlDecode', function() {
|
||||
encodings.forEach(function(encodingName) {
|
||||
it(encodingName, function () {
|
||||
var data = buffers[encodingName];
|
||||
var res = encoding.urlEncode(data);
|
||||
assert.equal(res, urlEncoded[getExpectedName(encodingName)]);
|
||||
assert.deepEqual(getCode(data), encoding.urlDecode(res));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('base64Encode/base64Decode', function() {
|
||||
encodings.forEach(function(encodingName) {
|
||||
it(encodingName, function () {
|
||||
var data = buffers[encodingName];
|
||||
var res = encoding.base64Encode(data);
|
||||
assert(typeof res === 'string');
|
||||
assert.equal(res, data.toString('base64'));
|
||||
assert.deepEqual(getCode(data), encoding.base64Decode(res));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Assign/Expect encoding names', function() {
|
||||
var aliasNames = {
|
||||
'UCS-4': 'UTF32BE',
|
||||
'UCS-2': 'UTF16BE',
|
||||
'UCS4': 'UTF32BE',
|
||||
'UCS2': 'UTF16BE',
|
||||
'ISO 646': 'ASCII',
|
||||
'CP367': 'ASCII',
|
||||
'Shift_JIS': 'SJIS',
|
||||
'x-sjis': 'SJIS',
|
||||
'SJIS-open': 'SJIS',
|
||||
'SJIS-win': 'SJIS',
|
||||
'SHIFT-JIS': 'SJIS',
|
||||
'SHIFT_JISX0213': 'SJIS',
|
||||
'CP932': 'SJIS',
|
||||
'Windows-31J': 'SJIS',
|
||||
'MS-Kanji': 'SJIS',
|
||||
'EUC-JP-MS': 'EUCJP',
|
||||
'eucJP-MS': 'EUCJP',
|
||||
'eucJP-open': 'EUCJP',
|
||||
'eucJP-win': 'EUCJP',
|
||||
'EUC-JPX0213': 'EUCJP',
|
||||
'EUC-JP': 'EUCJP',
|
||||
'eucJP': 'EUCJP',
|
||||
'ISO-2022-JP': 'JIS'
|
||||
};
|
||||
|
||||
var text = getExpectedText(getExpectedName('UTF-8'));
|
||||
var data = encoding.stringToCode(text);
|
||||
assert(data.length > 0);
|
||||
assert(encoding.detect(data, 'UNICODE'));
|
||||
|
||||
var sjis = encoding.convert(data, 'sjis');
|
||||
assert(sjis.length > 0);
|
||||
assert(encoding.detect(sjis, 'SJIS'));
|
||||
|
||||
var eucjp = encoding.convert(data, 'EUCJP');
|
||||
assert(eucjp.length > 0);
|
||||
assert(encoding.detect(eucjp, 'EUCJP'));
|
||||
|
||||
var codes = {
|
||||
'SJIS': sjis,
|
||||
'EUCJP': eucjp
|
||||
};
|
||||
|
||||
Object.keys(aliasNames).forEach(function(name) {
|
||||
it(name + ' is ' + aliasNames[name], function() {
|
||||
var encoded = encoding.convert(data, name);
|
||||
assert(encoded.length > 0);
|
||||
var encodingName = aliasNames[name];
|
||||
if (encodingName in codes) {
|
||||
var code = codes[encodingName];
|
||||
assert(code.length > 0);
|
||||
assert.equal(encoding.detect(code), encodingName);
|
||||
assert.deepEqual(encoded, code);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Result types of convert/detect', function() {
|
||||
var string = getExpectedText(getExpectedName('UTF-8'));
|
||||
assert(string.length > 0);
|
||||
|
||||
var array = encoding.stringToCode(string);
|
||||
assert(array.length > 0);
|
||||
assert(encoding.detect(array, 'UNICODE'));
|
||||
|
||||
var isTypedArray = function(a) {
|
||||
return !Array.isArray(a) && a != null &&
|
||||
typeof a.subarray !== 'undefined';
|
||||
};
|
||||
|
||||
var isString = function(a) {
|
||||
return typeof a === 'string';
|
||||
};
|
||||
|
||||
it('null/undefined', function() {
|
||||
var encoded = encoding.convert(null, 'utf-8');
|
||||
assert(encoded.length === 0);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
encoded = encoding.convert(void 0, 'utf-8');
|
||||
assert(encoded.length === 0);
|
||||
assert(Array.isArray(encoded));
|
||||
});
|
||||
|
||||
it('array by default', function() {
|
||||
var encoded = encoding.convert([], 'utf-8');
|
||||
assert(encoded.length === 0);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
encoded = encoding.convert([1], 'utf-8');
|
||||
assert(encoded.length === 1);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
encoded = encoding.convert(new Array(), 'utf-8');
|
||||
assert(encoded.length === 0);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
var a = new Array(2);
|
||||
a[0] = 1;
|
||||
a[1] = 2;
|
||||
encoded = encoding.convert(a, 'utf-8');
|
||||
assert(encoded.length === 2);
|
||||
assert(Array.isArray(encoded));
|
||||
});
|
||||
|
||||
it('Pass the string argument', function() {
|
||||
var encoded = encoding.convert('', 'utf-8');
|
||||
assert(encoded.length === 0);
|
||||
assert(isString(encoded));
|
||||
|
||||
encoded = encoding.convert('123', 'utf-8');
|
||||
assert(encoded.length === 3);
|
||||
assert(isString(encoded));
|
||||
|
||||
var utf8 = '\u00E3\u0081\u0093\u00E3\u0082\u0093\u00E3\u0081' +
|
||||
'\u00AB\u00E3\u0081\u00A1\u00E3\u0081\u00AF';
|
||||
|
||||
var expect = '\u3053\u3093\u306B\u3061\u306F';
|
||||
|
||||
encoded = encoding.convert(utf8, 'unicode', 'utf-8');
|
||||
assert(encoded.length > 0);
|
||||
assert(isString(encoded));
|
||||
assert.equal(encoded, expect);
|
||||
|
||||
var detected = encoding.detect(utf8);
|
||||
assert.equal(detected, 'UTF8');
|
||||
detected = encoding.detect(expect);
|
||||
assert.equal(detected, 'UNICODE');
|
||||
});
|
||||
|
||||
it('Specify { type: "array" }', function() {
|
||||
var encoded = encoding.convert(null, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'array'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
encoded = encoding.convert(void 0, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'array'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
encoded = encoding.convert('', {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'array'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
encoded = encoding.convert('123', {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'array'
|
||||
});
|
||||
assert(encoded.length === 3);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
encoded = encoding.convert([], {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'array'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
encoded = encoding.convert([0x61, 0x62], {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'array'
|
||||
});
|
||||
assert(encoded.length === 2);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
var buffer = new Buffer(0);
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'array'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
buffer = new Buffer(2);
|
||||
buffer[0] = 0x61;
|
||||
buffer[1] = 0x62;
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'array'
|
||||
});
|
||||
assert(encoded.length === 2);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
buffer = new Uint8Array(0);
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'array'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(Array.isArray(encoded));
|
||||
|
||||
buffer = new Uint8Array(2);
|
||||
buffer[0] = 0x61;
|
||||
buffer[1] = 0x62;
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'array'
|
||||
});
|
||||
assert(encoded.length === 2);
|
||||
assert(Array.isArray(encoded));
|
||||
});
|
||||
|
||||
it('Specify { type: "arraybuffer" }', function() {
|
||||
var encoded = encoding.convert(null, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'arraybuffer'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isTypedArray(encoded));
|
||||
|
||||
encoded = encoding.convert(void 0, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'arraybuffer'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isTypedArray(encoded));
|
||||
|
||||
encoded = encoding.convert('', {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'arraybuffer'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isTypedArray(encoded));
|
||||
|
||||
encoded = encoding.convert('123', {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'arraybuffer'
|
||||
});
|
||||
assert(encoded.length === 3);
|
||||
assert(isTypedArray(encoded));
|
||||
|
||||
encoded = encoding.convert([], {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'arraybuffer'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isTypedArray(encoded));
|
||||
|
||||
encoded = encoding.convert([0x61, 0x62], {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'arraybuffer'
|
||||
});
|
||||
assert(encoded.length === 2);
|
||||
assert(isTypedArray(encoded));
|
||||
|
||||
var buffer = new Buffer(0);
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'arraybuffer'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isTypedArray(encoded));
|
||||
|
||||
buffer = new Buffer(2);
|
||||
buffer[0] = 0x61;
|
||||
buffer[1] = 0x62;
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'arraybuffer'
|
||||
});
|
||||
assert(encoded.length === 2);
|
||||
assert(isTypedArray(encoded));
|
||||
|
||||
buffer = new Uint8Array(0);
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'arraybuffer'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isTypedArray(encoded));
|
||||
|
||||
buffer = new Uint8Array(2);
|
||||
buffer[0] = 0x61;
|
||||
buffer[1] = 0x62;
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'arraybuffer'
|
||||
});
|
||||
assert(encoded.length === 2);
|
||||
assert(isTypedArray(encoded));
|
||||
});
|
||||
|
||||
it('Specify { type: "string" }', function() {
|
||||
var encoded = encoding.convert(null, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'string'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isString(encoded));
|
||||
|
||||
encoded = encoding.convert(void 0, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'string'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isString(encoded));
|
||||
|
||||
encoded = encoding.convert('', {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'string'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isString(encoded));
|
||||
|
||||
encoded = encoding.convert('123', {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'string'
|
||||
});
|
||||
assert(encoded.length === 3);
|
||||
assert(isString(encoded));
|
||||
|
||||
encoded = encoding.convert([], {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'string'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isString(encoded));
|
||||
|
||||
encoded = encoding.convert([0x61, 0x62], {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'string'
|
||||
});
|
||||
assert(encoded.length === 2);
|
||||
assert(isString(encoded));
|
||||
|
||||
var buffer = new Buffer(0);
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'string'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isString(encoded));
|
||||
|
||||
buffer = new Buffer(2);
|
||||
buffer[0] = 0x61;
|
||||
buffer[1] = 0x62;
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'string'
|
||||
});
|
||||
assert(encoded.length === 2);
|
||||
assert(isString(encoded));
|
||||
|
||||
buffer = new Uint8Array(0);
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'string'
|
||||
});
|
||||
assert(encoded.length === 0);
|
||||
assert(isString(encoded));
|
||||
|
||||
buffer = new Uint8Array(2);
|
||||
buffer[0] = 0x61;
|
||||
buffer[1] = 0x62;
|
||||
encoded = encoding.convert(buffer, {
|
||||
to: 'utf-8',
|
||||
from: 'unicode',
|
||||
type: 'string'
|
||||
});
|
||||
assert(encoded.length === 2);
|
||||
assert(isString(encoded));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Japanese Zenkaku/Hankaku conversion', function() {
|
||||
var hankakus = [
|
||||
'Hello World! 12345',
|
||||
'!"#$%&\'()*+,-./0123456789:;<=>?@' +
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
|
||||
];
|
||||
|
||||
var zenkakus = [
|
||||
'Hello World! 12345',
|
||||
'!"#$%&'()*+,-./0123456789:;<=>?@' +
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
|
||||
];
|
||||
|
||||
var hankanas = [
|
||||
'ボポヴァアィイゥウェエォオ',
|
||||
'、。「」゙゚ァアィイゥウェエォオカキクケコサシスセソタチッツテト' +
|
||||
'ナニヌネノハヒフヘホマミムメモャヤュユョヨラリルレロワヲンヴヵヶヷヺ・ー'
|
||||
];
|
||||
|
||||
var zenkanas = [
|
||||
'ボポヴァアィイゥウェエォオ',
|
||||
'、。「」゛゜ァアィイゥウェエォオカキクケコサシスセソタチッツテト' +
|
||||
'ナニヌネノハヒフヘホマミムメモャヤュユョヨラリルレロワヲンヴヵヶ\u30F7\u30FA・ー'
|
||||
];
|
||||
|
||||
var hiraganas = [
|
||||
'ぼぽ\u3094ぁあぃいぅうぇえぉお',
|
||||
'、。「」゛゜ぁあぃいぅうぇえぉおかきくけこさしすせそたちっつてと' +
|
||||
'なにぬねのはひふへほまみむめもゃやゅゆょよらりるれろわをんう゛\u3094\u3095\u3096わ゛を゛・ー'
|
||||
];
|
||||
|
||||
var katakanas = [
|
||||
'ボポヴァアィイゥウェエォオ',
|
||||
'、。「」゛゜ァアィイゥウェエォオカキクケコサシスセソタチッツテト' +
|
||||
'ナニヌネノハヒフヘホマミムメモャヤュユョヨラリルレロワヲンウ゛ヴヵヶ\u30F7\u30FA・ー'
|
||||
];
|
||||
|
||||
var hanspace = 'Hello World! 1 2 3 4 5';
|
||||
var zenspace = 'Hello\u3000World!\u30001\u30002\u30003\u30004\u30005';
|
||||
|
||||
it('toHankakuCase', function() {
|
||||
zenkakus.forEach(function(zenkaku, i) {
|
||||
var expect = hankakus[i];
|
||||
var res = encoding.toHankakuCase(zenkaku);
|
||||
assert.equal(res, expect);
|
||||
|
||||
var zenkakuArray = encoding.stringToCode(zenkaku);
|
||||
var expectArray = encoding.stringToCode(expect);
|
||||
res = encoding.toHankakuCase(zenkakuArray);
|
||||
assert(Array.isArray(res));
|
||||
assert.deepEqual(res, expectArray);
|
||||
});
|
||||
});
|
||||
|
||||
it('toZenkakuCase', function() {
|
||||
hankakus.forEach(function(hankaku, i) {
|
||||
var expect = zenkakus[i];
|
||||
var res = encoding.toZenkakuCase(hankaku);
|
||||
assert.equal(res, expect);
|
||||
|
||||
var hankakuArray = encoding.stringToCode(hankaku);
|
||||
var expectArray = encoding.stringToCode(expect);
|
||||
res = encoding.toZenkakuCase(hankakuArray);
|
||||
assert(Array.isArray(res));
|
||||
assert.deepEqual(res, expectArray);
|
||||
});
|
||||
});
|
||||
|
||||
it('toHiraganaCase', function() {
|
||||
katakanas.forEach(function(katakana, i) {
|
||||
var expect = hiraganas[i];
|
||||
var res = encoding.toHiraganaCase(katakana);
|
||||
assert.equal(res, expect);
|
||||
|
||||
var zenkanaArray = encoding.stringToCode(katakana);
|
||||
var expectArray = encoding.stringToCode(expect);
|
||||
res = encoding.toHiraganaCase(zenkanaArray);
|
||||
assert(Array.isArray(res));
|
||||
assert.deepEqual(res, expectArray);
|
||||
});
|
||||
});
|
||||
|
||||
it('toKatakanaCase', function() {
|
||||
hiraganas.forEach(function(hiragana, i) {
|
||||
var expect = katakanas[i];
|
||||
var res = encoding.toKatakanaCase(hiragana);
|
||||
assert.equal(res, expect);
|
||||
|
||||
var hiraganaArray = encoding.stringToCode(hiragana);
|
||||
var expectArray = encoding.stringToCode(expect);
|
||||
res = encoding.toKatakanaCase(hiraganaArray);
|
||||
assert(Array.isArray(res));
|
||||
assert.deepEqual(res, expectArray);
|
||||
});
|
||||
});
|
||||
|
||||
it('toHankanaCase', function() {
|
||||
zenkanas.forEach(function(zenkana, i) {
|
||||
var expect = hankanas[i];
|
||||
var res = encoding.toHankanaCase(zenkana);
|
||||
assert.equal(res, expect);
|
||||
|
||||
var zenkanaArray = encoding.stringToCode(zenkana);
|
||||
var expectArray = encoding.stringToCode(expect);
|
||||
res = encoding.toHankanaCase(zenkanaArray);
|
||||
assert(Array.isArray(res));
|
||||
assert.deepEqual(res, expectArray);
|
||||
});
|
||||
});
|
||||
|
||||
it('toZenkanaCase', function() {
|
||||
hankanas.forEach(function(hankana, i) {
|
||||
var expect = zenkanas[i];
|
||||
var res = encoding.toZenkanaCase(hankana);
|
||||
assert.equal(res, expect);
|
||||
|
||||
var hankanaArray = encoding.stringToCode(hankana);
|
||||
var expectArray = encoding.stringToCode(expect);
|
||||
res = encoding.toZenkanaCase(hankanaArray);
|
||||
assert(Array.isArray(res));
|
||||
assert.deepEqual(res, expectArray);
|
||||
});
|
||||
});
|
||||
|
||||
it('toHankakuSpace', function() {
|
||||
var expect = hanspace;
|
||||
var res = encoding.toHankakuSpace(zenspace);
|
||||
assert.equal(res, expect);
|
||||
|
||||
var zenspaceArray = encoding.stringToCode(zenspace);
|
||||
var expectArray = encoding.stringToCode(expect);
|
||||
res = encoding.toHankakuSpace(zenspaceArray);
|
||||
assert(Array.isArray(res));
|
||||
assert.deepEqual(res, expectArray);
|
||||
});
|
||||
|
||||
it('toZenkakuSpace', function() {
|
||||
var expect = zenspace;
|
||||
var res = encoding.toZenkakuSpace(hanspace);
|
||||
assert.equal(res, expect);
|
||||
|
||||
var hanspaceArray = encoding.stringToCode(hanspace);
|
||||
var expectArray = encoding.stringToCode(expect);
|
||||
res = encoding.toZenkakuSpace(hanspaceArray);
|
||||
assert(Array.isArray(res));
|
||||
assert.deepEqual(res, expectArray);
|
||||
});
|
||||
});
|
||||
|
||||
describe('codeToString / stringToCode', function() {
|
||||
it('Test for JISX0208', function() {
|
||||
assert(Array.isArray(tests.jisx0208Array));
|
||||
assert(tests.jisx0208Array.length > 0);
|
||||
|
||||
var string = encoding.codeToString(tests.jisx0208Array);
|
||||
assert(typeof string === 'string');
|
||||
|
||||
var code = encoding.stringToCode(string);
|
||||
assert.deepEqual(code, tests.jisx0208Array);
|
||||
});
|
||||
|
||||
it('Test for a long string', function() {
|
||||
this.timeout(5000);
|
||||
|
||||
var config = require('../src/config');
|
||||
var longArray = [];
|
||||
var max = config.APPLY_BUFFER_SIZE;
|
||||
assert(typeof max === 'number');
|
||||
assert(max > 0);
|
||||
|
||||
while (longArray.length < max) {
|
||||
for (var i = 0; i < tests.jisx0208Array.length; i++) {
|
||||
longArray.push(tests.jisx0208Array[i]);
|
||||
}
|
||||
}
|
||||
assert(longArray.length > max);
|
||||
|
||||
var string = encoding.codeToString(longArray);
|
||||
assert(typeof string === 'string');
|
||||
var code = encoding.stringToCode(string);
|
||||
assert.deepEqual(code, longArray);
|
||||
|
||||
// Run 2 times to check if APPLY_BUFFER_SIZE_OK is set up expected
|
||||
string = encoding.codeToString(longArray);
|
||||
code = encoding.stringToCode(string);
|
||||
assert.deepEqual(code, longArray);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user