make_unicode 210 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348
  1. #!/usr/bin/perl -w
  2. #
  3. # Generate code page .c files from ftp.unicode.org descriptions
  4. #
  5. # Copyright 2000 Alexandre Julliard
  6. #
  7. # This library is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2.1 of the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with this library; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  20. #
  21. use strict;
  22. use XML::LibXML;
  23. use Encode;
  24. # base URLs for www.unicode.org files
  25. my $UNIVERSION = "14.0.0";
  26. my $UNIDATA = "https://www.unicode.org/Public/$UNIVERSION/ucd/UCD.zip";
  27. my $IDNADATA = "https://www.unicode.org/Public/idna/$UNIVERSION";
  28. my $JISDATA = "https://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS";
  29. my $KSCDATA = "https://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/KSC";
  30. my $REPORTS = "http://www.unicode.org/reports";
  31. my $MSDATA = "https://download.microsoft.com/download/C/F/7/CF713A5E-9FBC-4FD6-9246-275F65C0E498";
  32. my $MSCODEPAGES = "$MSDATA/Windows Supported Code Page Data Files.zip";
  33. my $CLDRVERSION = "41";
  34. my $CLDRDATA = "https://github.com/unicode-org/cldr/archive/refs/tags/release-$CLDRVERSION.zip";
  35. my $CLDR33DATA = "https://www.unicode.org/Public/cldr/33/cldr-common-33.0.zip";
  36. my $ISO639VERSION = "20220120";
  37. my $ISO639 = "https://iso639-3.sil.org/sites/iso639-3/files/downloads/iso-639-3_Code_Tables_$ISO639VERSION.zip";
  38. # Sort keys file
  39. my $SORTKEYS = "tr10/allkeys.txt";
  40. # Default char for undefined mappings
  41. my $DEF_CHAR = ord '?';
  42. # Last valid Unicode character
  43. my $MAX_CHAR = 0x10ffff;
  44. my @allfiles =
  45. (
  46. "CodpageFiles/037.txt",
  47. "CodpageFiles/437.txt",
  48. "CodpageFiles/500.txt",
  49. "CodpageFiles/708.txt",
  50. "CodpageFiles/720.txt",
  51. "CodpageFiles/737.txt",
  52. "CodpageFiles/775.txt",
  53. "CodpageFiles/850.txt",
  54. "CodpageFiles/852.txt",
  55. "CodpageFiles/855.txt",
  56. "CodpageFiles/857.txt",
  57. "CodpageFiles/860.txt",
  58. "CodpageFiles/861.txt",
  59. "CodpageFiles/862.txt",
  60. "CodpageFiles/863.txt",
  61. "CodpageFiles/864.txt",
  62. "CodpageFiles/865.txt",
  63. "CodpageFiles/866.txt",
  64. "CodpageFiles/869.txt",
  65. "CodpageFiles/874.txt",
  66. "CodpageFiles/875.txt",
  67. "CodpageFiles/932.txt",
  68. "CodpageFiles/936.txt",
  69. "CodpageFiles/949.txt",
  70. "CodpageFiles/950.txt",
  71. "CodpageFiles/1026.txt",
  72. "CodpageFiles/1250.txt",
  73. "CodpageFiles/1251.txt",
  74. "CodpageFiles/1252.txt",
  75. "CodpageFiles/1253.txt",
  76. "CodpageFiles/1254.txt",
  77. "CodpageFiles/1255.txt",
  78. "CodpageFiles/1256.txt",
  79. "CodpageFiles/1257.txt",
  80. "CodpageFiles/1258.txt",
  81. "CodpageFiles/1361.txt",
  82. "CodpageFiles/10000.txt",
  83. "CodpageFiles/10001.txt",
  84. "CodpageFiles/10002.txt",
  85. "CodpageFiles/10003.txt",
  86. "CodpageFiles/10004.txt",
  87. "CodpageFiles/10005.txt",
  88. "CodpageFiles/10006.txt",
  89. "CodpageFiles/10007.txt",
  90. "CodpageFiles/10008.txt",
  91. "CodpageFiles/10010.txt",
  92. "CodpageFiles/10017.txt",
  93. "CodpageFiles/10021.txt",
  94. "CodpageFiles/10029.txt",
  95. "CodpageFiles/10079.txt",
  96. "CodpageFiles/10081.txt",
  97. "CodpageFiles/10082.txt",
  98. "CodpageFiles/20127.txt",
  99. "CodpageFiles/20866.txt",
  100. "CodpageFiles/21866.txt",
  101. "CodpageFiles/28591.txt",
  102. "CodpageFiles/28592.txt",
  103. "CodpageFiles/28593.txt",
  104. "CodpageFiles/28594.txt",
  105. "CodpageFiles/28595.txt",
  106. "CodpageFiles/28596.txt",
  107. "CodpageFiles/28597.txt",
  108. "CodpageFiles/28598.txt",
  109. "CodpageFiles/28599.txt",
  110. "CodpageFiles/28603.txt",
  111. "CodpageFiles/28605.txt",
  112. );
  113. my %ctype =
  114. (
  115. # CT_CTYPE1
  116. "upper" => 0x0001,
  117. "lower" => 0x0002,
  118. "digit" => 0x0004,
  119. "space" => 0x0008,
  120. "punct" => 0x0010,
  121. "cntrl" => 0x0020,
  122. "blank" => 0x0040,
  123. "xdigit" => 0x0080,
  124. "alpha" => 0x0100 | 0x80000000,
  125. "defin" => 0x0200,
  126. # CT_CTYPE3 in high 16 bits
  127. "nonspacing" => 0x00010000,
  128. "diacritic" => 0x00020000,
  129. "vowelmark" => 0x00040000,
  130. "symbol" => 0x00080000,
  131. "katakana" => 0x00100000,
  132. "hiragana" => 0x00200000,
  133. "halfwidth" => 0x00400000,
  134. "fullwidth" => 0x00800000,
  135. "ideograph" => 0x01000000,
  136. "kashida" => 0x02000000,
  137. "lexical" => 0x04000000,
  138. "highsurrogate" => 0x08000000,
  139. "lowsurrogate" => 0x10000000,
  140. );
  141. my %bracket_types =
  142. (
  143. "o" => 0x0000,
  144. "c" => 0x0001,
  145. );
  146. my %indic_types =
  147. (
  148. "Other" => 0x0000,
  149. "Bindu" => 0x0001,
  150. "Visarga" => 0x0002,
  151. "Avagraha" => 0x0003,
  152. "Nukta" => 0x0004,
  153. "Virama" => 0x0005,
  154. "Vowel_Independent" => 0x0006,
  155. "Vowel_Dependent" => 0x0007,
  156. "Vowel" => 0x0008,
  157. "Consonant_Placeholder" => 0x0009,
  158. "Consonant" => 0x000a,
  159. "Consonant_Dead" => 0x000b,
  160. "Consonant_Succeeding_Repha" => 0x000c,
  161. "Consonant_Subjoined" => 0x000d,
  162. "Consonant_Medial" => 0x000e,
  163. "Consonant_Final" => 0x000f,
  164. "Consonant_Head_Letter" => 0x0010,
  165. "Modifying_Letter" => 0x0011,
  166. "Tone_Letter" => 0x0012,
  167. "Tone_Mark" => 0x0013,
  168. "Register_Shifter" => 0x0014,
  169. "Consonant_Preceding_Repha" => 0x0015,
  170. "Pure_Killer" => 0x0016,
  171. "Invisible_Stacker" => 0x0017,
  172. "Gemination_Mark" => 0x0018,
  173. "Cantillation_Mark" => 0x0019,
  174. "Non_Joiner" => 0x001a,
  175. "Joiner" => 0x001b,
  176. "Number_Joiner" => 0x001c,
  177. "Number" => 0x001d,
  178. "Brahmi_Joining_Number" => 0x001e,
  179. "Consonant_With_Stacker" => 0x001f,
  180. "Consonant_Prefixed" => 0x0020,
  181. "Syllable_Modifier" => 0x0021,
  182. "Consonant_Killer" => 0x0022,
  183. "Consonant_Initial_Postfixed" => 0x0023,
  184. );
  185. my %matra_types =
  186. (
  187. "Right" => 0x01,
  188. "Left" => 0x02,
  189. "Visual_Order_Left" => 0x03,
  190. "Left_And_Right" => 0x04,
  191. "Top" => 0x05,
  192. "Bottom" => 0x06,
  193. "Top_And_Bottom" => 0x07,
  194. "Top_And_Right" => 0x08,
  195. "Top_And_Left" => 0x09,
  196. "Top_And_Left_And_Right" => 0x0a,
  197. "Bottom_And_Right" => 0x0b,
  198. "Top_And_Bottom_And_Right" => 0x0c,
  199. "Overstruck" => 0x0d,
  200. "Invisible" => 0x0e,
  201. "Bottom_And_Left" => 0x0f,
  202. "Top_And_Bottom_And_Left" => 0x10,
  203. );
  204. my %break_types =
  205. (
  206. "BK" => 0x0001,
  207. "CR" => 0x0002,
  208. "LF" => 0x0003,
  209. "CM" => 0x0004,
  210. "SG" => 0x0005,
  211. "GL" => 0x0006,
  212. "CB" => 0x0007,
  213. "SP" => 0x0008,
  214. "ZW" => 0x0009,
  215. "NL" => 0x000a,
  216. "WJ" => 0x000b,
  217. "JL" => 0x000c,
  218. "JV" => 0x000d,
  219. "JT" => 0x000e,
  220. "H2" => 0x000f,
  221. "H3" => 0x0010,
  222. "XX" => 0x0011,
  223. "OP" => 0x0012,
  224. "CL" => 0x0013,
  225. "CP" => 0x0014,
  226. "QU" => 0x0015,
  227. "NS" => 0x0016,
  228. "EX" => 0x0017,
  229. "SY" => 0x0018,
  230. "IS" => 0x0019,
  231. "PR" => 0x001a,
  232. "PO" => 0x001b,
  233. "NU" => 0x001c,
  234. "AL" => 0x001d,
  235. "ID" => 0x001e,
  236. "IN" => 0x001f,
  237. "HY" => 0x0020,
  238. "BB" => 0x0021,
  239. "BA" => 0x0022,
  240. "SA" => 0x0023,
  241. "AI" => 0x0024,
  242. "B2" => 0x0025,
  243. "HL" => 0x0026,
  244. "CJ" => 0x0027,
  245. "RI" => 0x0028,
  246. "EB" => 0x0029,
  247. "EM" => 0x002a,
  248. "ZWJ" => 0x002b,
  249. );
  250. my %vertical_types =
  251. (
  252. "R" => 0x0000,
  253. "U" => 0x0001,
  254. "Tr" => 0x0002,
  255. "Tu" => 0x0003,
  256. );
  257. my %categories =
  258. (
  259. "Lu" => $ctype{"defin"}|$ctype{"alpha"}|$ctype{"upper"}, # Letter, Uppercase
  260. "Ll" => $ctype{"defin"}|$ctype{"alpha"}|$ctype{"lower"}, # Letter, Lowercase
  261. "Lt" => $ctype{"defin"}|$ctype{"alpha"}|$ctype{"upper"}|$ctype{"lower"}, # Letter, Titlecase
  262. "Mn" => $ctype{"defin"}|$ctype{"nonspacing"}, # Mark, Non-Spacing
  263. "Mc" => $ctype{"defin"}, # Mark, Spacing Combining
  264. "Me" => $ctype{"defin"}, # Mark, Enclosing
  265. "Nd" => $ctype{"defin"}|$ctype{"digit"}, # Number, Decimal Digit
  266. "Nl" => $ctype{"defin"}|$ctype{"alpha"}, # Number, Letter
  267. "No" => $ctype{"defin"}, # Number, Other
  268. "Zs" => $ctype{"defin"}|$ctype{"space"}, # Separator, Space
  269. "Zl" => $ctype{"defin"}|$ctype{"space"}, # Separator, Line
  270. "Zp" => $ctype{"defin"}|$ctype{"space"}, # Separator, Paragraph
  271. "Cc" => $ctype{"defin"}|$ctype{"cntrl"}, # Other, Control
  272. "Cf" => $ctype{"defin"}|$ctype{"cntrl"}, # Other, Format
  273. "Cs" => $ctype{"defin"}, # Other, Surrogate
  274. "Co" => $ctype{"defin"}, # Other, Private Use
  275. "Cn" => $ctype{"defin"}, # Other, Not Assigned
  276. "Lm" => $ctype{"defin"}|$ctype{"alpha"}, # Letter, Modifier
  277. "Lo" => $ctype{"defin"}|$ctype{"alpha"}, # Letter, Other
  278. "Pc" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Connector
  279. "Pd" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Dash
  280. "Ps" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Open
  281. "Pe" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Close
  282. "Pi" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Initial quote
  283. "Pf" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Final quote
  284. "Po" => $ctype{"defin"}|$ctype{"punct"}, # Punctuation, Other
  285. "Sm" => $ctype{"defin"}|$ctype{"symbol"}, # Symbol, Math
  286. "Sc" => $ctype{"defin"}|$ctype{"symbol"}, # Symbol, Currency
  287. "Sk" => $ctype{"defin"}|$ctype{"symbol"}, # Symbol, Modifier
  288. "So" => $ctype{"defin"}|$ctype{"symbol"} # Symbol, Other
  289. );
  290. # a few characters need additional categories that cannot be determined automatically
  291. my %special_categories =
  292. (
  293. "xdigit" => [ ord('0')..ord('9'),ord('A')..ord('F'),ord('a')..ord('f'),
  294. 0xff10..0xff19, 0xff21..0xff26, 0xff41..0xff46 ],
  295. "space" => [ 0x09..0x0d, 0x85 ],
  296. "blank" => [ 0x09, 0x20, 0xa0, 0x3000, 0xfeff ],
  297. "cntrl" => [ 0x070f, 0x200c, 0x200d,
  298. 0x200e, 0x200f, 0x202a, 0x202b, 0x202c, 0x202d, 0x202e,
  299. 0x206a, 0x206b, 0x206c, 0x206d, 0x206e, 0x206f, 0xfeff,
  300. 0xfff9, 0xfffa, 0xfffb ],
  301. "punct" => [ 0x24, 0x2b, 0x3c..0x3e, 0x5e, 0x60, 0x7c, 0x7e, 0xa2..0xbe,
  302. 0xd7, 0xf7 ],
  303. "digit" => [ 0xb2, 0xb3, 0xb9 ],
  304. "lower" => [ 0xaa, 0xba, 0x2071, 0x207f ],
  305. "nonspacing" => [ 0xc0..0xc5, 0xc7..0xcf, 0xd1..0xd6, 0xd8..0xdd, 0xe0..0xe5, 0xe7..0xef,
  306. 0xf1..0xf6, 0xf8..0xfd, 0xff, 0x6de, 0x1929..0x192b, 0x302e..0x302f ],
  307. "diacritic" => [ 0x5e, 0x60, 0xb7, 0xd8, 0xf8 ],
  308. "symbol" => [ 0x09..0x0d, 0x20..0x23, 0x25, 0x26, 0x28..0x2a, 0x2c, 0x2e..0x2f, 0x3a..0x40,
  309. 0x5b..0x60, 0x7b..0x7e, 0xa0..0xa9, 0xab..0xb1, 0xb4..0xb8, 0xbb, 0xbf,
  310. 0x02b9..0x02ba, 0x02c6..0x02cf ],
  311. "halfwidth" => [ 0x20..0x7e, 0xa2..0xa3, 0xa5..0xa6, 0xac, 0xaf, 0x20a9 ],
  312. "fullwidth" => [ 0x2018..0x2019, 0x201c..0x201d, 0x3000..0x3002, 0x300c..0x300d, 0x309b..0x309c,
  313. 0x30a1..0x30ab, 0x30ad, 0x30ad, 0x30af, 0x30b1, 0x30b3, 0x30b5, 0x30b7, 0x30b9,
  314. 0x30bb, 0x30bd, 0x30bf, 0x30c1, 0x30c3, 0x30c4, 0x30c6, 0x30c8, 0x30ca..0x30cf,
  315. 0x30d2, 0x30d5, 0x30d8, 0x30db, 0x30de..0x30ed, 0x30ef, 0x30f2..0x30f3, 0x30fb,
  316. 0x3131..0x3164 ],
  317. "ideograph" => [ 0x3006..0x3007 ],
  318. "lexical" => [ 0x22, 0x24, 0x27, 0x2d, 0x2f, 0x3d, 0x40, 0x5c, 0x5e..0x60, 0x7e,
  319. 0xa8, 0xaa, 0xad, 0xaf, 0xb4, 0xb8, 0xba,
  320. 0x02b0..0x02b8, 0x02bc, 0x02c7, 0x02ca..0x02cb, 0x02cf, 0x02d8..0x02dd, 0x02e0..0x02e3,
  321. 0x037a, 0x0384..0x0385, 0x0387, 0x0559..0x055a, 0x0640, 0x1fbd..0x1fc1,
  322. 0x1fcd..0x1fcf, 0x1fdd..0x1fdf, 0x1fed..0x1fef, 0x1ffd..0x1ffe, 0x2010..0x2015,
  323. 0x2032..0x2034, 0x2038, 0x2043..0x2044, 0x207b..0x207c, 0x207f, 0x208b..0x208c,
  324. 0x2212, 0x2215..0x2216, 0x2500, 0x2504..0x2505, 0x2508..0x2509, 0x254c..0x254d,
  325. 0x3003, 0x301c, 0x3030..0x3035, 0x309b..0x309e, 0x30fd..0x30fe, 0xfe31..0xfe32,
  326. 0xfe58, 0xfe63, 0xfe66, 0xfe68..0xfe69, 0xfe6b, 0xff04, 0xff07, 0xff0d, 0xff0f,
  327. 0xff1d, 0xff20, 0xff3c, 0xff3e, 0xff40, 0xff5e ],
  328. "kashida" => [ 0x0640 ],
  329. );
  330. my %directions =
  331. (
  332. "L" => 1, # Left-to-Right
  333. "R" => 2, # Right-to-Left
  334. "AL" => 12, # Right-to-Left Arabic
  335. "EN" => 3, # European Number
  336. "ES" => 4, # European Number Separator
  337. "ET" => 5, # European Number Terminator
  338. "AN" => 6, # Arabic Number
  339. "CS" => 7, # Common Number Separator
  340. "NSM" => 13, # Non-Spacing Mark
  341. "BN" => 14, # Boundary Neutral
  342. "B" => 8, # Paragraph Separator
  343. "S" => 9, # Segment Separator
  344. "WS" => 10, # Whitespace
  345. "ON" => 11, # Other Neutrals
  346. "LRE" => 15, # Left-to-Right Embedding
  347. "LRO" => 15, # Left-to-Right Override
  348. "RLE" => 15, # Right-to-Left Embedding
  349. "RLO" => 15, # Right-to-Left Override
  350. "PDF" => 15, # Pop Directional Format
  351. "LRI" => 15, # Left-to-Right Isolate
  352. "RLI" => 15, # Right-to-Left Isolate
  353. "FSI" => 15, # First Strong Isolate
  354. "PDI" => 15 # Pop Directional Isolate
  355. );
  356. my %c2_types =
  357. (
  358. "L" => 1, # C2_LEFTTORIGHT
  359. "R" => 2, # C2_RIGHTTOLEFT
  360. "AL" => 2, # C2_RIGHTTOLEFT
  361. "EN" => 3, # C2_EUROPENUMBER
  362. "ES" => 4, # C2_EUROPESEPARATOR
  363. "ET" => 5, # C2_EUROPETERMINATOR
  364. "AN" => 6, # C2_ARABICNUMBER
  365. "CS" => 7, # C2_COMMONSEPARATOR
  366. "NSM" => 11, # C2_OTHERNEUTRAL
  367. "BN" => 0, # C2_NOTAPPLICABLE
  368. "B" => 8, # C2_BLOCKSEPARATOR
  369. "S" => 9, # C2_SEGMENTSEPARATOR
  370. "WS" => 10, # C2_WHITESPACE
  371. "ON" => 11, # C2_OTHERNEUTRAL
  372. "LRE" => 11, # C2_OTHERNEUTRAL
  373. "LRO" => 11, # C2_OTHERNEUTRAL
  374. "RLE" => 11, # C2_OTHERNEUTRAL
  375. "RLO" => 11, # C2_OTHERNEUTRAL
  376. "PDF" => 11, # C2_OTHERNEUTRAL
  377. "LRI" => 11, # C2_OTHERNEUTRAL
  378. "RLI" => 11, # C2_OTHERNEUTRAL
  379. "FSI" => 11, # C2_OTHERNEUTRAL
  380. "PDI" => 11 # C2_OTHERNEUTRAL
  381. );
  382. my %bidi_types =
  383. (
  384. "ON" => 0, # Other Neutrals
  385. "L" => 1, # Left-to-Right
  386. "R" => 2, # Right-to-Left
  387. "AN" => 3, # Arabic Number
  388. "EN" => 4, # European Number
  389. "AL" => 5, # Right-to-Left Arabic
  390. "NSM" => 6, # Non-Spacing Mark
  391. "CS" => 7, # Common Number Separator
  392. "ES" => 8, # European Number Separator
  393. "ET" => 9, # European Number Terminator
  394. "BN" => 10, # Boundary Neutral
  395. "S" => 11, # Segment Separator
  396. "WS" => 12, # Whitespace
  397. "B" => 13, # Paragraph Separator
  398. "RLO" => 14, # Right-to-Left Override
  399. "RLE" => 15, # Right-to-Left Embedding
  400. "LRO" => 16, # Left-to-Right Override
  401. "LRE" => 17, # Left-to-Right Embedding
  402. "PDF" => 18, # Pop Directional Format
  403. "LRI" => 19, # Left-to-Right Isolate
  404. "RLI" => 20, # Right-to-Left Isolate
  405. "FSI" => 21, # First Strong Isolate
  406. "PDI" => 22 # Pop Directional Isolate
  407. );
  408. my %joining_types =
  409. (
  410. "U" => 0, # Non_Joining
  411. "L" => 1, # Left_Joining
  412. "R" => 2, # Right_Joining
  413. "D" => 3, # Dual_Joining
  414. "C" => 3, # Join_Causing
  415. "ALAPH" => 4, # Syriac ALAPH
  416. "DALATH RISH" => 5, # Syriac DALATH RISH group
  417. "T" => 6, # Transparent
  418. );
  419. my @locales =
  420. (
  421. { name => "", lcid => 0x0000007f, file => "root", territory => "IV", sabbrevlangname => "IVL", sopentypelang =>"dflt" },
  422. { name => "aa", dir => "seed", sopentypelang => "AFR" },
  423. { name => "aa-DJ", dir => "seed" },
  424. { name => "aa-ER", dir => "seed" },
  425. { name => "aa-ET", dir => "seed" },
  426. { name => "af", lcid => 0x00000036, oemcp => 850, sabbrevlangname => "AFK", sopentypelang => "AFK" },
  427. { name => "af-NA" },
  428. { name => "af-ZA", lcid => 0x00000436 },
  429. { name => "agq" },
  430. { name => "agq-CM" },
  431. { name => "ak", sopentypelang => "TWI" },
  432. { name => "ak-GH" },
  433. { name => "am", lcid => 0x0000005e, sabbrevlangname => "AMH" },
  434. { name => "am-ET", lcid => 0x0000045e },
  435. { name => "ar", lcid => 0x00000001, territory => "SA", oemcp => 720, group => 13 },
  436. { name => "ar-001" },
  437. { name => "ar-AE", lcid => 0x00003801, sabbrevlangname => "ARU" },
  438. { name => "ar-BH", lcid => 0x00003c01, sabbrevlangname => "ARH" },
  439. { name => "ar-DJ" },
  440. { name => "ar-DZ", lcid => 0x00001401, sabbrevlangname => "ARG" },
  441. { name => "ar-EG", lcid => 0x00000c01, sabbrevlangname => "ARE" },
  442. { name => "ar-EH" },
  443. { name => "ar-ER" },
  444. { name => "ar-IL" },
  445. { name => "ar-IQ", lcid => 0x00000801, sabbrevlangname => "ARI" },
  446. { name => "ar-JO", lcid => 0x00002c01, sabbrevlangname => "ARJ" },
  447. { name => "ar-KM" },
  448. { name => "ar-KW", lcid => 0x00003401, sabbrevlangname => "ARK" },
  449. { name => "ar-LB", lcid => 0x00003001, sabbrevlangname => "ARB" },
  450. { name => "ar-LY", lcid => 0x00001001, sabbrevlangname => "ARL" },
  451. { name => "ar-MA", lcid => 0x00001801, sabbrevlangname => "ARM" },
  452. { name => "ar-MR" },
  453. { name => "ar-OM", lcid => 0x00002001, sabbrevlangname => "ARO" },
  454. { name => "ar-PS" },
  455. { name => "ar-QA", lcid => 0x00004001, sabbrevlangname => "ARQ" },
  456. { name => "ar-SA", lcid => 0x00000401, sabbrevlangname => "ARA" },
  457. { name => "ar-SD" },
  458. { name => "ar-SO" },
  459. { name => "ar-SS" },
  460. { name => "ar-SY", lcid => 0x00002801, sabbrevlangname => "ARS" },
  461. { name => "ar-TD" },
  462. { name => "ar-TN", lcid => 0x00001c01, sabbrevlangname => "ART" },
  463. { name => "ar-YE", lcid => 0x00002401, sabbrevlangname => "ARY" },
  464. { name => "arn", lcid => 0x0000007a, oemcp => 850, ebcdiccp => 20284, slist => ",", dir => "seed", sabbrevlangname => "MPD", sopentypelang => "MAP" },
  465. { name => "arn-CL", lcid => 0x0000047a, dir => "seed" },
  466. { name => "arn-Latn", alias => "arn" },
  467. { name => "arn-Latn-CL", alias => "arn-CL" },
  468. { name => "as", lcid => 0x0000004d, slist => ",", group => 15 },
  469. { name => "as-IN", lcid => 0x0000044d },
  470. { name => "asa" },
  471. { name => "asa-TZ" },
  472. { name => "ast" },
  473. { name => "ast-ES" },
  474. { name => "az", lcid => 0x0000002c, oemcp => 857, ebcdiccp => 20905, group => 2 },
  475. { name => "az-Cyrl", lcid => 0x0000742c, oemcp => 866, ebcdiccp => 20880, group => 5, sabbrevlangname => "AZC" },
  476. { name => "az-Cyrl-AZ", lcid => 0x0000082c },
  477. { name => "az-Latn", lcid => 0x0000782c },
  478. { name => "az-Latn-AZ", lcid => 0x0000042c },
  479. { name => "ba", lcid => 0x0000006d, oemcp => 866, group => 5, dir => "seed", sabbrevlangname => "BAS", sopentypelang => "BSH" },
  480. { name => "ba-Cyrl", alias => "ba" },
  481. { name => "ba-Cyrl-RU", alias => "ba-RU" },
  482. { name => "ba-RU", lcid => 0x0000046d, dir => "seed" },
  483. { name => "bas" },
  484. { name => "bas-CM" },
  485. { name => "be", lcid => 0x00000023, oemcp => 866, ebcdiccp => 500, group => 5 },
  486. { name => "be-BY", lcid => 0x00000423 },
  487. { name => "bem" },
  488. { name => "bem-ZM" },
  489. { name => "bez" },
  490. { name => "bez-TZ" },
  491. { name => "bg", lcid => 0x00000002, oemcp => 866, ebcdiccp => 21025, group => 5, sabbrevlangname => "BGR", sopentypelang => "BGR" },
  492. { name => "bg-BG", lcid => 0x00000402 },
  493. { name => "bin", lcid => 0x00000066, oemcp => 850, dir => "exemplars", sabbrevlangname => "ZZZ", sopentypelang => "EDO" },
  494. { name => "bin-NG", lcid => 0x00000466, file => "bin", dir => "exemplars" },
  495. { name => "bm", sopentypelang => "BMB" },
  496. { name => "bm-Latn", file => "bm" },
  497. { name => "bm-Latn-ML", file => "bm_ML" },
  498. { name => "bm-ML", alias => "bm-Latn-ML" },
  499. { name => "bn", lcid => 0x00000045, slist => ",", group => 15, sabbrevlangname => "BNB" },
  500. { name => "bn-BD", lcid => 0x00000845 },
  501. { name => "bn-IN", lcid => 0x00000445, sabbrevlangname => "BNG" },
  502. { name => "bo", lcid => 0x00000051, slist => ",", group => 15, sabbrevlangname => "BOB", sopentypelang => "TIB" },
  503. { name => "bo-CN", lcid => 0x00000451 },
  504. { name => "bo-IN", slist => "," },
  505. { name => "bo-Tibt", alias => "bo" },
  506. { name => "bo-Tibt-CN", alias => "bo-CN" },
  507. { name => "bo-Tibt-IN", alias => "bo-IN" },
  508. { name => "br", lcid => 0x0000007e, oemcp => 850, ebcdiccp => 20297 },
  509. { name => "br-FR", lcid => 0x0000047e },
  510. { name => "br-Latn", alias => "br" },
  511. { name => "br-Latn-FR", alias => "br-FR" },
  512. { name => "brx" },
  513. { name => "brx-IN" },
  514. { name => "bs", lcid => 0x0000781a, oemcp => 852, maccp => 10082, ebcdiccp => 870, group => 2, sabbrevlangname => "BSB" },
  515. { name => "bs-Cyrl", lcid => 0x0000641a, oemcp => 855, group => 5, sabbrevlangname => "BSC" },
  516. { name => "bs-Cyrl-BA", lcid => 0x0000201a },
  517. { name => "bs-Latn", lcid => 0x0000681a },
  518. { name => "bs-Latn-BA", lcid => 0x0000141a },
  519. { name => "byn", dir => "seed", sopentypelang => "BIL" },
  520. { name => "byn-ER", dir => "seed" },
  521. { name => "ca", lcid => 0x00000003, oemcp => 850 },
  522. { name => "ca-AD", maccp => 65001 },
  523. { name => "ca-ES", lcid => 0x00000403 },
  524. { name => "ca-ES-valencia", lcid => 0x00000803, file => "ca_ES_VALENCIA", sabbrevlangname => "VAL" },
  525. { name => "ca-FR", maccp => 65001 },
  526. { name => "ca-IT", maccp => 65001 },
  527. { name => "ccp" },
  528. { name => "ccp-BD", alias => "ccp-Cakm-BD" },
  529. { name => "ccp-Cakm", file => "ccp" },
  530. { name => "ccp-Cakm-BD", file => "ccp_BD" },
  531. { name => "ccp-Cakm-IN", file => "ccp_IN" },
  532. { name => "ccp-IN", alias => "ccp-Cakm-IN" },
  533. { name => "ce" },
  534. { name => "ce-RU" },
  535. { name => "ceb" },
  536. { name => "ceb-Latn", file => "ceb" },
  537. { name => "ceb-Latn-PH", file => "ceb_PH" },
  538. { name => "ceb-PH", alias => "ceb-Latn-PH" },
  539. { name => "cgg" },
  540. { name => "cgg-UG" },
  541. { name => "chr", lcid => 0x0000005c, slist => ",", sabbrevlangname => "CRE" },
  542. { name => "chr-Cher", lcid => 0x00007c5c, file => "chr" },
  543. { name => "chr-Cher-US", lcid => 0x0000045c, file => "chr_US" },
  544. { name => "chr-US", alias => "chr-Cher-US" },
  545. { name => "ckb", alias => "ku" },
  546. { name => "ckb-IQ", alias => "ku-Arab-IQ" },
  547. { name => "ckb-IR", alias => "ku-Arab-IR" },
  548. { name => "co", lcid => 0x00000083, oemcp => 850, ebcdiccp => 20297, dir => "seed" },
  549. { name => "co-FR", lcid => 0x00000483, dir => "seed" },
  550. { name => "co-Latn", alias => "co" },
  551. { name => "co-Latn-FR", alias => "co-FR" },
  552. { name => "cs", lcid => 0x00000005, oemcp => 852, group => 2, sabbrevlangname => "CSY", sopentypelang => "CSY" },
  553. { name => "cs-CZ", lcid => 0x00000405 },
  554. { name => "cu", dir => "seed", sopentypelang => "CSL" },
  555. { name => "cu-RU", dir => "seed" },
  556. { name => "cy", lcid => 0x00000052, oemcp => 850, ebcdiccp => 20285, sabbrevlangname => "CYM", sopentypelang => "WEL" },
  557. { name => "cy-GB", lcid => 0x00000452 },
  558. { name => "da", lcid => 0x00000006, oemcp => 850, ebcdiccp => 20277 },
  559. { name => "da-DK", lcid => 0x00000406 },
  560. { name => "da-GL", maccp => 65001 },
  561. { name => "dav" },
  562. { name => "dav-KE" },
  563. { name => "de", lcid => 0x00000007, oemcp => 850, ebcdiccp => 20273 },
  564. { name => "de-AT", lcid => 0x00000c07, sabbrevlangname => "DEA" },
  565. { name => "de-BE" },
  566. { name => "de-CH", lcid => 0x00000807, sabbrevlangname => "DES" },
  567. { name => "de-DE", lcid => 0x00000407 },
  568. { name => "de-DE_phoneb", lcid => 0x00010407, alias => "de-DE" },
  569. { name => "de-DE-u-co-phonebk", alias => "de-DE_phoneb" },
  570. { name => "de-IT", oemcp => 65001 },
  571. { name => "de-LI", lcid => 0x00001407, sabbrevlangname => "DEC" },
  572. { name => "de-LU", lcid => 0x00001007, sabbrevlangname => "DEL" },
  573. { name => "dje", sopentypelang => "DJR" },
  574. { name => "dje-NE" },
  575. { name => "doi" },
  576. { name => "doi-IN" },
  577. { name => "dsb", lcid => 0x00007c2e, sparent => "hsb", oemcp => 850, ebcdiccp => 870, sabbrevlangname => "DSB", sopentypelang => "LSB" },
  578. { name => "dsb-DE", lcid => 0x0000082e },
  579. { name => "dua" },
  580. { name => "dua-CM" },
  581. { name => "dv", lcid => 0x00000065, slist => "\x{060c}", group => 13, dir => "seed" },
  582. { name => "dv-MV", lcid => 0x00000465, dir => "seed" },
  583. { name => "dyo" },
  584. { name => "dyo-SN" },
  585. { name => "dz", sopentypelang => "DZN" },
  586. { name => "dz-BT", lcid => 0x00000c51, sabbrevlangname => "ZZZ" },
  587. { name => "ebu" },
  588. { name => "ebu-KE" },
  589. { name => "ee" },
  590. { name => "ee-GH" },
  591. { name => "ee-TG" },
  592. { name => "el", lcid => 0x00000008, oemcp => 737, group => 4 },
  593. { name => "el-CY" },
  594. { name => "el-GR", lcid => 0x00000408 },
  595. { name => "en", lcid => 0x00000009, oemcp => 437, slist => ",", sabbrevlangname => "ENU" },
  596. { name => "en-001", oemcp => 850 },
  597. { name => "en-029", lcid => 0x00002409, file => "en", oemcp => 850, sabbrevlangname => "ENB" },
  598. { name => "en-150", oemcp => 65001 },
  599. { name => "en-AE", lcid => 0x00004c09, oemcp => 65001, sabbrevlangname => "ZZZ" },
  600. { name => "en-AG", oemcp => 850 },
  601. { name => "en-AI", oemcp => 850 },
  602. { name => "en-AS", oemcp => 850 },
  603. { name => "en-AT", oemcp => 65001 },
  604. { name => "en-AU", lcid => 0x00000c09, oemcp => 850, sabbrevlangname => "ENA" },
  605. { name => "en-BB", oemcp => 850 },
  606. { name => "en-BE", oemcp => 850 },
  607. { name => "en-BI", oemcp => 65001 },
  608. { name => "en-BM", oemcp => 850 },
  609. { name => "en-BS", oemcp => 850 },
  610. { name => "en-BW", oemcp => 850 },
  611. { name => "en-BZ", lcid => 0x00002809, oemcp => 850, sabbrevlangname => "ENL" },
  612. { name => "en-CA", lcid => 0x00001009, oemcp => 850, ebcdiccp => 37, sabbrevlangname => "ENC" },
  613. { name => "en-CC", oemcp => 850 },
  614. { name => "en-CH", oemcp => 65001 },
  615. { name => "en-CK", oemcp => 850 },
  616. { name => "en-CM", oemcp => 850 },
  617. { name => "en-CX", oemcp => 850 },
  618. { name => "en-CY", oemcp => 65001 },
  619. { name => "en-DE", oemcp => 65001 },
  620. { name => "en-DG", oemcp => 850 },
  621. { name => "en-DK", oemcp => 65001 },
  622. { name => "en-DM", oemcp => 850 },
  623. { name => "en-ER", oemcp => 850 },
  624. { name => "en-FI", oemcp => 65001 },
  625. { name => "en-FJ", oemcp => 850 },
  626. { name => "en-FK", oemcp => 850 },
  627. { name => "en-FM", oemcp => 850 },
  628. { name => "en-GB", lcid => 0x00000809, oemcp => 850, ebcdiccp => 20285, sabbrevlangname => "ENG" },
  629. { name => "en-GD", oemcp => 850 },
  630. { name => "en-GG", oemcp => 850 },
  631. { name => "en-GH", oemcp => 850 },
  632. { name => "en-GI", oemcp => 850 },
  633. { name => "en-GM", oemcp => 850 },
  634. { name => "en-GU", oemcp => 850 },
  635. { name => "en-GY", oemcp => 850 },
  636. { name => "en-HK", lcid => 0x00003c09, oemcp => 850, sabbrevlangname => "ENH" },
  637. { name => "en-ID", lcid => 0x00003809, file => "en", oemcp => 850, sabbrevlangname => "ZZZ" },
  638. { name => "en-IE", lcid => 0x00001809, oemcp => 850, sabbrevlangname => "ENI" },
  639. { name => "en-IL", oemcp => 65001 },
  640. { name => "en-IM", oemcp => 850 },
  641. { name => "en-IN", lcid => 0x00004009, sabbrevlangname => "ENN" },
  642. { name => "en-IO", oemcp => 850 },
  643. { name => "en-JE", oemcp => 850 },
  644. { name => "en-JM", lcid => 0x00002009, oemcp => 850, sabbrevlangname => "ENJ" },
  645. { name => "en-KE", oemcp => 850 },
  646. { name => "en-KI", oemcp => 850 },
  647. { name => "en-KN", oemcp => 850 },
  648. { name => "en-KY", oemcp => 850 },
  649. { name => "en-LC", oemcp => 850 },
  650. { name => "en-LR", oemcp => 850 },
  651. { name => "en-LS", oemcp => 850 },
  652. { name => "en-MG", oemcp => 850 },
  653. { name => "en-MH", oemcp => 850 },
  654. { name => "en-MO", oemcp => 850 },
  655. { name => "en-MP", oemcp => 850 },
  656. { name => "en-MS", oemcp => 850 },
  657. { name => "en-MT", oemcp => 850 },
  658. { name => "en-MU", oemcp => 850 },
  659. { name => "en-MW", oemcp => 850 },
  660. { name => "en-MY", lcid => 0x00004409, sabbrevlangname => "ENM" },
  661. { name => "en-NA", oemcp => 850 },
  662. { name => "en-NF", oemcp => 850 },
  663. { name => "en-NG", oemcp => 850 },
  664. { name => "en-NL", oemcp => 65001 },
  665. { name => "en-NR", oemcp => 850 },
  666. { name => "en-NU", oemcp => 850 },
  667. { name => "en-NZ", lcid => 0x00001409, oemcp => 850, sabbrevlangname => "ENZ" },
  668. { name => "en-PG", oemcp => 850 },
  669. { name => "en-PH", lcid => 0x00003409, ebcdiccp => 500, sabbrevlangname => "ENP" },
  670. { name => "en-PK", oemcp => 850 },
  671. { name => "en-PN", oemcp => 850 },
  672. { name => "en-PR", oemcp => 850 },
  673. { name => "en-PW", oemcp => 850 },
  674. { name => "en-RW", oemcp => 850 },
  675. { name => "en-SB", oemcp => 850 },
  676. { name => "en-SC", oemcp => 850 },
  677. { name => "en-SD", oemcp => 850 },
  678. { name => "en-SE", oemcp => 65001 },
  679. { name => "en-SG", lcid => 0x00004809, sabbrevlangname => "ENE" },
  680. { name => "en-SH", oemcp => 850 },
  681. { name => "en-SI", oemcp => 65001 },
  682. { name => "en-SL", oemcp => 850 },
  683. { name => "en-SS", oemcp => 850 },
  684. { name => "en-SX", oemcp => 850 },
  685. { name => "en-SZ", oemcp => 850 },
  686. { name => "en-TC", oemcp => 850 },
  687. { name => "en-TK", oemcp => 850 },
  688. { name => "en-TO", oemcp => 850 },
  689. { name => "en-TT", lcid => 0x00002c09, oemcp => 850, sabbrevlangname => "ENT" },
  690. { name => "en-TV", oemcp => 850 },
  691. { name => "en-TZ", oemcp => 850 },
  692. { name => "en-UG", oemcp => 850 },
  693. { name => "en-UM", oemcp => 850 },
  694. { name => "en-US", lcid => 0x00000409 },
  695. { name => "en-VC", oemcp => 850 },
  696. { name => "en-VG", oemcp => 850 },
  697. { name => "en-VI", oemcp => 850 },
  698. { name => "en-VU", oemcp => 850 },
  699. { name => "en-WS", oemcp => 850 },
  700. { name => "en-ZA", lcid => 0x00001c09, ebcdiccp => 500, sabbrevlangname => "ENS" },
  701. { name => "en-ZM", oemcp => 850 },
  702. { name => "en-ZW", lcid => 0x00003009, ebcdiccp => 500, sabbrevlangname => "ENW" },
  703. { name => "eo", sopentypelang => "NTO" },
  704. { name => "eo-001" },
  705. { name => "es", lcid => 0x0000000a, oemcp => 850, ebcdiccp => 20284, sabbrevlangname => "ESP", sopentypelang => "ESP" },
  706. { name => "es-419", lcid => 0x0000580a, sabbrevlangname => "ESJ" },
  707. { name => "es-AR", lcid => 0x00002c0a, sabbrevlangname => "ESS" },
  708. { name => "es-BO", lcid => 0x0000400a, sabbrevlangname => "ESB" },
  709. { name => "es-BR", oemcp => 65001 },
  710. { name => "es-BZ", oemcp => 65001 },
  711. { name => "es-CL", lcid => 0x0000340a, sabbrevlangname => "ESL" },
  712. { name => "es-CO", lcid => 0x0000240a, sabbrevlangname => "ESO" },
  713. { name => "es-CR", lcid => 0x0000140a, sabbrevlangname => "ESC" },
  714. { name => "es-CU", lcid => 0x00005c0a, sabbrevlangname => "ESK" },
  715. { name => "es-DO", lcid => 0x00001c0a, sabbrevlangname => "ESD" },
  716. { name => "es-EA" },
  717. { name => "es-EC", lcid => 0x0000300a, sabbrevlangname => "ESF" },
  718. { name => "es-ES", lcid => 0x00000c0a, sabbrevlangname => "ESN" },
  719. { name => "es-ES_tradnl", lcid => 0x0000040a, file => "es_ES" },
  720. { name => "es-ES-u-co-trad", alias => "es-ES_tradnl" },
  721. { name => "es-GQ" },
  722. { name => "es-GT", lcid => 0x0000100a, sabbrevlangname => "ESG" },
  723. { name => "es-HN", lcid => 0x0000480a, sabbrevlangname => "ESH" },
  724. { name => "es-IC" },
  725. { name => "es-MX", lcid => 0x0000080a, sabbrevlangname => "ESM" },
  726. { name => "es-NI", lcid => 0x00004c0a, sabbrevlangname => "ESI" },
  727. { name => "es-PA", lcid => 0x0000180a, sabbrevlangname => "ESA" },
  728. { name => "es-PE", lcid => 0x0000280a, sabbrevlangname => "ESR" },
  729. { name => "es-PH" },
  730. { name => "es-PR", lcid => 0x0000500a, sabbrevlangname => "ESU" },
  731. { name => "es-PY", lcid => 0x00003c0a, sabbrevlangname => "ESZ" },
  732. { name => "es-SV", lcid => 0x0000440a, sabbrevlangname => "ESE" },
  733. { name => "es-US", lcid => 0x0000540a, sabbrevlangname => "EST" },
  734. { name => "es-UY", lcid => 0x0000380a, sabbrevlangname => "ESY" },
  735. { name => "es-VE", lcid => 0x0000200a, sabbrevlangname => "ESV" },
  736. { name => "et", lcid => 0x00000025, oemcp => 775, group => 3, sabbrevlangname => "ETI", sopentypelang => "ETI" },
  737. { name => "et-EE", lcid => 0x00000425 },
  738. { name => "eu", lcid => 0x0000002d, oemcp => 850, maccp => 65001, sabbrevlangname => "EUQ", sopentypelang => "EUQ" },
  739. { name => "eu-ES", lcid => 0x0000042d },
  740. { name => "ewo" },
  741. { name => "ewo-CM" },
  742. { name => "fa", lcid => 0x00000029, inegnumber => 3, oemcp => 720, slist => "\x{061b}", group => 13, sabbrevlangname => "FAR", sopentypelang => "FAR" },
  743. { name => "fa-AF", alias => "prs-AF" },
  744. { name => "fa-IR", lcid => 0x00000429 },
  745. { name => "ff", lcid => 0x00000067, oemcp => 850, ebcdiccp => 20297 },
  746. { name => "ff-CM", alias => "ff-Latn-CM" },
  747. { name => "ff-GN", alias => "ff-Latn-GN" },
  748. { name => "ff-MR", alias => "ff-Latn-MR" },
  749. { name => "ff-NG", alias => "ff-Latn-NG" },
  750. { name => "ff-SN", alias => "ff-Latn-SN" },
  751. { name => "ff-Adlm" },
  752. { name => "ff-Adlm-BF" },
  753. { name => "ff-Adlm-CM" },
  754. { name => "ff-Adlm-GH" },
  755. { name => "ff-Adlm-GM" },
  756. { name => "ff-Adlm-GN" },
  757. { name => "ff-Adlm-GW" },
  758. { name => "ff-Adlm-LR" },
  759. { name => "ff-Adlm-MR" },
  760. { name => "ff-Adlm-NE" },
  761. { name => "ff-Adlm-NG" },
  762. { name => "ff-Adlm-SL" },
  763. { name => "ff-Adlm-SN" },
  764. { name => "ff-Latn", lcid => 0x00007c67 },
  765. { name => "ff-Latn-BF", oemcp => 65001 },
  766. { name => "ff-Latn-CM" },
  767. { name => "ff-Latn-GH", oemcp => 65001 },
  768. { name => "ff-Latn-GM", oemcp => 65001 },
  769. { name => "ff-Latn-GN" },
  770. { name => "ff-Latn-GW", oemcp => 65001 },
  771. { name => "ff-Latn-LR", oemcp => 65001 },
  772. { name => "ff-Latn-MR" },
  773. { name => "ff-Latn-NE", oemcp => 65001 },
  774. { name => "ff-Latn-NG", lcid => 0x00000467, sabbrevlangname => "ZZZ" },
  775. { name => "ff-Latn-SL", oemcp => 65001 },
  776. { name => "ff-Latn-SN", lcid => 0x00000867 },
  777. { name => "fi", lcid => 0x0000000b, oemcp => 850, ebcdiccp => 20278 },
  778. { name => "fi-FI", lcid => 0x0000040b },
  779. { name => "fil", lcid => 0x00000064, oemcp => 437, ebcdiccp => 500, sabbrevlangname => "FPO", sopentypelang => "PIL" },
  780. { name => "fil-PH", lcid => 0x00000464 },
  781. { name => "fil-Latn", alias => "fil" },
  782. { name => "fil-Latn-PH", alias => "fil-PH" },
  783. { name => "fo", lcid => 0x00000038, oemcp => 850, maccp => 10079, ebcdiccp => 20277, sabbrevlangname => "FOS", sopentypelang => "FOS" },
  784. { name => "fo-DK", oemcp => 65001, maccp => 65001 },
  785. { name => "fo-FO", lcid => 0x00000438 },
  786. { name => "fr", lcid => 0x0000000c, oemcp => 850, ebcdiccp => 20297 },
  787. { name => "fr-029", lcid => 0x00001c0c, file => "fr", sabbrevlangname => "ZZZ" },
  788. { name => "fr-BE", lcid => 0x0000080c, sabbrevlangname => "FRB" },
  789. { name => "fr-BF" },
  790. { name => "fr-BI" },
  791. { name => "fr-BJ" },
  792. { name => "fr-BL" },
  793. { name => "fr-CA", lcid => 0x00000c0c, sabbrevlangname => "FRC" },
  794. { name => "fr-CD", lcid => 0x0000240c, sabbrevlangname => "FRD" },
  795. { name => "fr-CF" },
  796. { name => "fr-CG" },
  797. { name => "fr-CH", lcid => 0x0000100c, sabbrevlangname => "FRS" },
  798. { name => "fr-CI", lcid => 0x0000300c, sabbrevlangname => "FRI" },
  799. { name => "fr-CM", lcid => 0x00002c0c, sabbrevlangname => "FRE" },
  800. { name => "fr-DJ" },
  801. { name => "fr-DZ" },
  802. { name => "fr-FR", lcid => 0x0000040c },
  803. { name => "fr-GA" },
  804. { name => "fr-GF" },
  805. { name => "fr-GN" },
  806. { name => "fr-GP" },
  807. { name => "fr-GQ" },
  808. { name => "fr-HT", lcid => 0x00003c0c, sabbrevlangname => "FRH" },
  809. { name => "fr-KM" },
  810. { name => "fr-LU", lcid => 0x0000140c, sabbrevlangname => "FRL" },
  811. { name => "fr-MA", lcid => 0x0000380c, sabbrevlangname => "FRO" },
  812. { name => "fr-MC", lcid => 0x0000180c, sabbrevlangname => "FRM" },
  813. { name => "fr-MF" },
  814. { name => "fr-MG" },
  815. { name => "fr-ML", lcid => 0x0000340c, sabbrevlangname => "FRF" },
  816. { name => "fr-MQ" },
  817. { name => "fr-MR" },
  818. { name => "fr-MU" },
  819. { name => "fr-NC" },
  820. { name => "fr-NE" },
  821. { name => "fr-PF" },
  822. { name => "fr-PM" },
  823. { name => "fr-RE", lcid => 0x0000200c, sabbrevlangname => "FRR" },
  824. { name => "fr-RW" },
  825. { name => "fr-SC" },
  826. { name => "fr-SN", lcid => 0x0000280c, sabbrevlangname => "FRN" },
  827. { name => "fr-SY" },
  828. { name => "fr-TD" },
  829. { name => "fr-TG" },
  830. { name => "fr-TN" },
  831. { name => "fr-VU" },
  832. { name => "fr-WF" },
  833. { name => "fr-YT" },
  834. { name => "fur", sopentypelang => "FRL" },
  835. { name => "fur-IT" },
  836. { name => "fy", lcid => 0x00000062, oemcp => 850, sabbrevlangname => "FYN", sopentypelang => "FRI" },
  837. { name => "fy-NL", lcid => 0x00000462 },
  838. { name => "ga", lcid => 0x0000003c, oemcp => 850, sabbrevlangname => "IRE", sopentypelang => "IRI" },
  839. { name => "ga-GB" },
  840. { name => "ga-IE", lcid => 0x0000083c },
  841. { name => "gd", lcid => 0x00000091, oemcp => 850, ebcdiccp => 20285, sopentypelang => "GAE" },
  842. { name => "gd-GB", lcid => 0x00000491 },
  843. { name => "gd-Latn", alias => "gd" },
  844. { name => "gl", lcid => 0x00000056, oemcp => 850, sabbrevlangname => "GLC", sopentypelang => "GAL" },
  845. { name => "gl-ES", lcid => 0x00000456 },
  846. { name => "gn", lcid => 0x00000074, oemcp => 850, ebcdiccp => 20284, slist => ",", dir => "seed", sopentypelang => "GUA" },
  847. { name => "gn-PY", lcid => 0x00000474, dir => "seed" },
  848. { name => "gsw", lcid => 0x00000084, oemcp => 850, ebcdiccp => 20297, sabbrevlangname => "ZZZ", sopentypelang => "ALS" },
  849. { name => "gsw-CH" },
  850. { name => "gsw-FR", lcid => 0x00000484, sabbrevlangname => "GSW" },
  851. { name => "gsw-LI" },
  852. { name => "gu", lcid => 0x00000047, slist => ",", group => 15 },
  853. { name => "gu-IN", lcid => 0x00000447 },
  854. { name => "guz" },
  855. { name => "guz-KE" },
  856. { name => "gv", sopentypelang => "MNX" },
  857. { name => "gv-IM" },
  858. { name => "ha", lcid => 0x00000068, oemcp => 437 },
  859. { name => "ha-GH", alias => "ha-Latn-GH" },
  860. { name => "ha-Latn", lcid => 0x00007c68, file => "ha" },
  861. { name => "ha-Latn-GH", file => "ha_GH", ebcdiccp => 500 },
  862. { name => "ha-Latn-NE", file => "ha_NE", ebcdiccp => 500 },
  863. { name => "ha-Latn-NG", lcid => 0x00000468, file => "ha_NG" },
  864. { name => "ha-NE", alias => "ha-Latn-NE" },
  865. { name => "ha-NG", alias => "ha-Latn-NG" },
  866. { name => "haw", lcid => 0x00000075, oemcp => 437 },
  867. { name => "haw-Latn", alias => "haw" },
  868. { name => "haw-Latn-US", alias => "haw-US" },
  869. { name => "haw-US", lcid => 0x00000475 },
  870. { name => "he", lcid => 0x0000000d, oemcp => 862, slist => ",", group => 12, sopentypelang => "IWR" },
  871. { name => "he-IL", lcid => 0x0000040d },
  872. { name => "hi", lcid => 0x00000039, slist => ",", group => 15 },
  873. { name => "hi-IN", lcid => 0x00000439 },
  874. { name => "hr", lcid => 0x0000001a, inegnumber => 2, oemcp => 852, maccp => 10082, group => 2 },
  875. { name => "hr-BA", lcid => 0x0000101a, ebcdiccp => 870, inegnumber => 1, sabbrevlangname => "HRB" },
  876. { name => "hr-HR", lcid => 0x0000041a },
  877. { name => "hsb", lcid => 0x0000002e, oemcp => 850, ebcdiccp => 870, sopentypelang => "USB" },
  878. { name => "hsb-DE", lcid => 0x0000042e },
  879. { name => "hu", lcid => 0x0000000e, oemcp => 852, group => 2 },
  880. { name => "hu-HU", lcid => 0x0000040e },
  881. { name => "hu-HU_technl", lcid => 0x0001040e, alias => "hu-HU" },
  882. { name => "hy", lcid => 0x0000002b, slist => ",", group => 17 },
  883. { name => "hy-AM", lcid => 0x0000042b },
  884. { name => "ia" },
  885. { name => "ia-001" },
  886. ## name => "ibb", lcid => 0x00000069 },
  887. ## name => "ibb-NG", lcid => 0x00000469 },
  888. { name => "id", lcid => 0x00000021, oemcp => 850 },
  889. { name => "id-ID", lcid => 0x00000421 },
  890. { name => "ig", lcid => 0x00000070, oemcp => 437 },
  891. { name => "ig-Latn", alias => "ig" },
  892. { name => "ig-Latn-NG", alias => "ig-NG" },
  893. { name => "ig-NG", lcid => 0x00000470 },
  894. { name => "ii", lcid => 0x00000078, group => 9, sopentypelang => "YIM" },
  895. { name => "ii-CN", lcid => 0x00000478 },
  896. { name => "ii-Yiii", alias => "ii" },
  897. { name => "ii-Yiii-CN", alias => "ii-CN" },
  898. { name => "is", lcid => 0x0000000f, oemcp => 850, maccp => 10079, ebcdiccp => 20871 },
  899. { name => "is-IS", lcid => 0x0000040f },
  900. { name => "it", lcid => 0x00000010, oemcp => 850, ebcdiccp => 20280 },
  901. { name => "it-CH", lcid => 0x00000810, ebcdiccp => 500, sabbrevlangname => "ITS" },
  902. { name => "it-IT", lcid => 0x00000410 },
  903. { name => "it-SM" },
  904. { name => "it-VA", oemcp => 65001 },
  905. { name => "iu", lcid => 0x0000005d, oemcp => 437, slist => ",", sortlocale => "iu-Latn-CA", dir => "seed", sabbrevlangname => "IUK", sopentypelang => "INU" },
  906. { name => "iu-Cans", lcid => 0x0000785d, file => "iu", oemcp => 65001, dir => "seed", sabbrevlangname => "IUS" },
  907. { name => "iu-Cans-CA", lcid => 0x0000045d, file => "iu_CA", dir => "seed" },
  908. { name => "iu-Latn", lcid => 0x00007c5d, dir => "seed" },
  909. { name => "iu-Latn-CA", lcid => 0x0000085d, dir => "seed" },
  910. { name => "ja", lcid => 0x00000011, ireadinglayout => 2, oemcp => 932, slist => ",", sscripts => "Hani Hira Jpan Kana", group => 7, sopentypelang => "JAN" },
  911. { name => "ja-JP", lcid => 0x00000411 },
  912. { name => "ja-JP_radstr", lcid => 0x00040411, alias => "ja-JP" },
  913. { name => "ja-JP-u-co-unihan", alias => "ja-JP_radstr" },
  914. { name => "jgo" },
  915. { name => "jgo-CM" },
  916. { name => "jmc" },
  917. { name => "jmc-TZ" },
  918. { name => "jv", oemcp => 850 },
  919. { name => "jv-ID", alias => "jv-Latn-ID" },
  920. ## name => "jv-Java" },
  921. ## name => "jv-Java-ID" },
  922. { name => "jv-Latn", file => "jv" },
  923. { name => "jv-Latn-ID", file => "jv_ID" },
  924. { name => "ka", lcid => 0x00000037, group => 16 },
  925. { name => "ka-GE", lcid => 0x00000437 },
  926. { name => "ka-GE_modern", lcid => 0x00010437, alias => "ka-GE" },
  927. { name => "kab", sopentypelang => "KAB0" },
  928. { name => "kab-DZ" },
  929. { name => "kam", sopentypelang => "KMB" },
  930. { name => "kam-KE" },
  931. { name => "kde" },
  932. { name => "kde-TZ" },
  933. { name => "kea" },
  934. { name => "kea-CV" },
  935. { name => "kgp" },
  936. { name => "kgp-BR" },
  937. { name => "khq" },
  938. { name => "khq-ML" },
  939. { name => "ki" },
  940. { name => "ki-KE" },
  941. { name => "kk", lcid => 0x0000003f, group => 5, sabbrevlangname => "KKZ" },
  942. { name => "kk-Cyrl", alias => "kk" },
  943. { name => "kk-Cyrl-KZ", alias => "kk-KZ" },
  944. { name => "kk-KZ", lcid => 0x0000043f },
  945. { name => "kkj" },
  946. { name => "kkj-CM" },
  947. { name => "kl", lcid => 0x0000006f, oemcp => 850, ebcdiccp => 20277, sopentypelang => "GRN" },
  948. { name => "kl-GL", lcid => 0x0000046f },
  949. { name => "kln", sopentypelang => "KAL" },
  950. { name => "kln-KE" },
  951. { name => "km", lcid => 0x00000053, inegnumber => 2, slist => ",", group => 15 },
  952. { name => "km-KH", lcid => 0x00000453 },
  953. { name => "kn", lcid => 0x0000004b, slist => ",", group => 15, sabbrevlangname => "KDI" },
  954. { name => "kn-IN", lcid => 0x0000044b },
  955. { name => "ko", lcid => 0x00000012, ireadinglayout => 2, slist => ",", oemcp => 949, ebcdiccp => 20833, sscripts => "Hang Hani Kore", group => 8 },
  956. { name => "ko-KP", oemcp => 65001 },
  957. { name => "ko-KR", lcid => 0x00000412 },
  958. { name => "kok", lcid => 0x00000057, slist => ",", group => 15, sabbrevlangname => "KNK" },
  959. { name => "kok-IN", lcid => 0x00000457 },
  960. { name => "kr", lcid => 0x00000071, sortlocale => "kr-Latn-NG", oemcp => 850, dir => "exemplars", sabbrevlangname => "ZZZ", sopentypelang => "KNR" },
  961. { name => "kr-Latn", file => "kr", dir => "exemplars" },
  962. { name => "kr-Latn-NG", lcid => 0x00000471, file => "kr", dir => "exemplars" },
  963. { name => "kr-NG", alias => "kr-Latn-NG" },
  964. { name => "ks", lcid => 0x00000060, group => 15, sabbrevlangname => "ZZZ", sopentypelang => "KSH" },
  965. { name => "ks-Arab", lcid => 0x00000460 },
  966. { name => "ks-Arab-IN" },
  967. { name => "ks-Deva", slist => "," },
  968. { name => "ks-Deva-IN", lcid => 0x00000860 },
  969. { name => "ks-IN", alias => "ks-Arab-IN" },
  970. { name => "ksb" },
  971. { name => "ksb-TZ" },
  972. { name => "ksf" },
  973. { name => "ksf-CM" },
  974. { name => "ksh", sopentypelang => "KSH0" },
  975. { name => "ksh-DE" },
  976. { name => "ku", lcid => 0x00000092, file => "ckb", slist => "\x{061b}", sortlocale => "ku-Arab-IQ", oemcp => 720 },
  977. { name => "ku-Arab", lcid => 0x00007c92, file => "ckb", group => 13 },
  978. { name => "ku-Arab-IQ", lcid => 0x00000492, file => "ckb_IQ" },
  979. { name => "ku-Arab-IR", file => "ckb_IR", oemcp => 65001 },
  980. { name => "kw" },
  981. { name => "kw-GB" },
  982. { name => "ky", lcid => 0x00000040, oemcp => 866, group => 5, sabbrevlangname => "KYR" },
  983. { name => "ky-Cyrl", alias => "ky" },
  984. { name => "ky-Cyrl-KG", alias => "ky-KG" },
  985. { name => "ky-KG", lcid => 0x00000440 },
  986. { name => "la", lcid => 0x00000076, oemcp => 437, slist => ",", dir => "seed", sabbrevlangname => "ZZZ" },
  987. { name => "la-001", lcid => 0x00000476, file => "la", dir => "seed" },
  988. { name => "lag" },
  989. { name => "lag-TZ" },
  990. { name => "lb", lcid => 0x0000006e, oemcp => 850, ebcdiccp => 20297, sabbrevlangname => "LBX" },
  991. { name => "lb-LU", lcid => 0x0000046e },
  992. { name => "lg" },
  993. { name => "lg-UG" },
  994. { name => "lkt" },
  995. { name => "lkt-US" },
  996. { name => "ln" },
  997. { name => "ln-AO" },
  998. { name => "ln-CD" },
  999. { name => "ln-CF" },
  1000. { name => "ln-CG" },
  1001. { name => "lo", lcid => 0x00000054, group => 15 },
  1002. { name => "lo-LA", lcid => 0x00000454 },
  1003. { name => "lrc" },
  1004. { name => "lrc-IQ" },
  1005. { name => "lrc-IR" },
  1006. { name => "lt", lcid => 0x00000027, oemcp => 775, group => 3, sabbrevlangname => "LTH", sopentypelang => "LTH" },
  1007. { name => "lt-LT", lcid => 0x00000427 },
  1008. { name => "lu" },
  1009. { name => "lu-CD" },
  1010. { name => "luo" },
  1011. { name => "luo-KE" },
  1012. { name => "luy", sopentypelang => "LUH" },
  1013. { name => "luy-KE" },
  1014. { name => "lv", lcid => 0x00000026, oemcp => 775, group => 3, sabbrevlangname => "LVI", sopentypelang => "LVI" },
  1015. { name => "lv-LV", lcid => 0x00000426 },
  1016. { name => "mai" },
  1017. { name => "mai-IN" },
  1018. { name => "mas" },
  1019. { name => "mas-KE" },
  1020. { name => "mas-TZ" },
  1021. { name => "mer" },
  1022. { name => "mer-KE" },
  1023. { name => "mfe" },
  1024. { name => "mfe-MU" },
  1025. { name => "mg" },
  1026. { name => "mg-MG" },
  1027. { name => "mgh" },
  1028. { name => "mgh-MZ" },
  1029. { name => "mgo" },
  1030. { name => "mgo-CM" },
  1031. { name => "mi", lcid => 0x00000081, slist => "," },
  1032. { name => "mi-Latn", alias => "mi" },
  1033. { name => "mi-Latn-NZ", alias => "mi-NZ" },
  1034. { name => "mi-NZ", lcid => 0x00000481 },
  1035. { name => "mk", lcid => 0x0000002f, oemcp => 866, ebcdiccp => 500, group => 5, sabbrevlangname => "MKI" },
  1036. { name => "mk-MK", lcid => 0x0000042f },
  1037. { name => "ml", lcid => 0x0000004c, group => 15, sabbrevlangname => "MYM", sopentypelang => "MLR" },
  1038. { name => "ml-IN", lcid => 0x0000044c },
  1039. { name => "mn", lcid => 0x00000050, oemcp => 866, sopentypelang => "MNG" },
  1040. { name => "mn-Cyrl", lcid => 0x00007850, file => "mn", sabbrevlangname => "MNN" },
  1041. { name => "mn-Cyrl-MN", alias => "mn-MN" },
  1042. { name => "mn-MN", lcid => 0x00000450, sparent => "mn-Cyrl", group => 5 },
  1043. { name => "mn-Mong", lcid => 0x00007c50, oemcp => 65001, slist => ",", group => 15, dir => "seed", sabbrevlangname => "MNG" },
  1044. { name => "mn-Mong-CN", lcid => 0x00000850, dir => "seed" },
  1045. { name => "mn-Mong-MN", lcid => 0x00000c50, dir => "seed", sabbrevlangname => "MNM" },
  1046. { name => "mni", lcid => 0x00000058, slist => ",", sabbrevlangname => "ZZZ" },
  1047. { name => "mni-IN", lcid => 0x00000458, file => "mni_Beng_IN" },
  1048. { name => "moh", lcid => 0x0000007c, oemcp => 850, ebcdiccp => 37, slist => ",", dir => "seed", sabbrevlangname => "MWK" },
  1049. { name => "moh-CA", lcid => 0x0000047c, dir => "seed" },
  1050. { name => "moh-Latn", alias => "moh" },
  1051. { name => "moh-Latn-CA", alias => "moh-CA" },
  1052. { name => "mr", lcid => 0x0000004e, slist => ",", group => 15 },
  1053. { name => "mr-IN", lcid => 0x0000044e },
  1054. { name => "ms", lcid => 0x0000003e, oemcp => 850, sabbrevlangname => "MSL", sopentypelang => "MLY" },
  1055. { name => "ms-BN", lcid => 0x0000083e, sabbrevlangname => "MSB" },
  1056. { name => "ms-ID" },
  1057. { name => "ms-Latn", alias => "ms" },
  1058. { name => "ms-Latn-BN", alias => "ms-BN" },
  1059. { name => "ms-Latn-MY", alias => "ms-MY" },
  1060. { name => "ms-Latn-SG", alias => "ms-SG" },
  1061. { name => "ms-MY", lcid => 0x0000043e },
  1062. { name => "ms-SG" },
  1063. { name => "mt", lcid => 0x0000003a, sopentypelang => "MTS" },
  1064. { name => "mt-MT", lcid => 0x0000043a },
  1065. { name => "mua" },
  1066. { name => "mua-CM" },
  1067. { name => "my", lcid => 0x00000055, sopentypelang => "BRM" },
  1068. { name => "my-MM", lcid => 0x00000455 },
  1069. { name => "mzn" },
  1070. { name => "mzn-IR" },
  1071. { name => "naq" },
  1072. { name => "naq-NA" },
  1073. { name => "nb", lcid => 0x00007c14, oemcp => 850, ebcdiccp => 20277, sabbrevlangname => "NOR", sopentypelang => "NOR" },
  1074. { name => "nb-NO", lcid => 0x00000414 },
  1075. { name => "nb-SJ" },
  1076. { name => "nd", sopentypelang => "NDB" },
  1077. { name => "nd-ZW" },
  1078. { name => "nds" },
  1079. { name => "nds-DE" },
  1080. { name => "nds-NL" },
  1081. { name => "ne", lcid => 0x00000061, slist => "," },
  1082. { name => "ne-IN", lcid => 0x00000861, sabbrevlangname => "NEI" },
  1083. { name => "ne-NP", lcid => 0x00000461, group => 15 },
  1084. { name => "nl", lcid => 0x00000013, oemcp => 850 },
  1085. { name => "nl-AW" },
  1086. { name => "nl-BE", lcid => 0x00000813, sabbrevlangname => "NLB" },
  1087. { name => "nl-BQ" },
  1088. { name => "nl-CW" },
  1089. { name => "nl-NL", lcid => 0x00000413 },
  1090. { name => "nl-SR" },
  1091. { name => "nl-SX" },
  1092. { name => "nmg" },
  1093. { name => "nmg-CM" },
  1094. { name => "nn", lcid => 0x00007814, oemcp => 850, ebcdiccp => 20277, sabbrevlangname => "NON", sopentypelang => "NYN" },
  1095. { name => "nn-NO", lcid => 0x00000814 },
  1096. { name => "nnh" },
  1097. { name => "nnh-CM" },
  1098. { name => "no", lcid => 0x00000014, oemcp => 850, ebcdiccp => 20277, sortlocale => "nb-NO" },
  1099. { name => "nqo", idigits => 3, inegnumber => 3, slist => "\x{060c}", dir => "seed", sopentypelang => "NKO" },
  1100. { name => "nqo-GN", dir => "seed" },
  1101. { name => "nr", dir => "seed", sopentypelang => "NDB" },
  1102. { name => "nr-ZA", dir => "seed" },
  1103. { name => "nso", lcid => 0x0000006c, oemcp => 850, dir => "seed", sopentypelang => "SOT" },
  1104. { name => "nso-ZA", lcid => 0x0000046c, dir => "seed" },
  1105. { name => "nus" },
  1106. { name => "nus-SD", alias => "nus-SS" },
  1107. { name => "nus-SS" },
  1108. { name => "nyn", sopentypelang => "NKL" },
  1109. { name => "nyn-UG" },
  1110. { name => "oc", lcid => 0x00000082, oemcp => 850, ebcdiccp => 20297, dir => "seed" },
  1111. { name => "oc-FR", lcid => 0x00000482, dir => "seed" },
  1112. { name => "oc-Latn", alias => "oc" },
  1113. { name => "oc-Latn-FR", alias => "oc-FR" },
  1114. { name => "om", lcid => 0x00000072, sopentypelang => "ORO" },
  1115. { name => "om-ET", lcid => 0x00000472 },
  1116. { name => "om-KE" },
  1117. { name => "or", lcid => 0x00000048, slist => ",", group => 15 },
  1118. { name => "or-IN", lcid => 0x00000448 },
  1119. { name => "os" },
  1120. { name => "os-GE" },
  1121. { name => "os-RU" },
  1122. { name => "pa", lcid => 0x00000046, slist => "," },
  1123. { name => "pa-Arab", lcid => 0x00007c46, slist => ";", inegnumber => 2, oemcp => 720, group => 13, sabbrevlangname => "PAP" },
  1124. { name => "pa-Arab-PK", lcid => 0x00000846 },
  1125. { name => "pa-Guru" },
  1126. { name => "pa-Guru-IN", alias => "pa-IN" },
  1127. { name => "pa-IN", lcid => 0x00000446, sparent => "pa-Guru", file => "pa_Guru_IN", group => 15 },
  1128. ## name => "pap", lcid => 0x00000079 },
  1129. ## name => "pap-029", lcid => 0x00000479 },
  1130. { name => "pcm" },
  1131. { name => "pcm-NG" },
  1132. { name => "pl", lcid => 0x00000015, oemcp => 852, ebcdiccp => 20880, group => 2, sabbrevlangname => "PLK", sopentypelang => "PLK" },
  1133. { name => "pl-PL", lcid => 0x00000415 },
  1134. ## name => "prg" },
  1135. ## name => "prg-001" },
  1136. { name => "prs", lcid => 0x0000008c, file => "fa", inegnumber => 3, oemcp => 720, group => 13, sopentypelang => "DRI" },
  1137. { name => "prs-AF", lcid => 0x0000048c, file => "fa_AF" },
  1138. { name => "prs-Arab", alias => "prs" },
  1139. { name => "prs-Arab-AF", alias => "prs-AF" },
  1140. { name => "ps", lcid => 0x00000063, group => 13, sabbrevlangname => "PAS", sopentypelang => "PAS" },
  1141. { name => "ps-AF", lcid => 0x00000463 },
  1142. { name => "ps-PK" },
  1143. { name => "pt", lcid => 0x00000016, oemcp => 850, sabbrevlangname => "PTB", sopentypelang => "PTG" },
  1144. { name => "pt-AO" },
  1145. { name => "pt-BR", lcid => 0x00000416 },
  1146. { name => "pt-CH", oemcp => 65001 },
  1147. { name => "pt-CV" },
  1148. { name => "pt-GQ", oemcp => 65001 },
  1149. { name => "pt-GW" },
  1150. { name => "pt-LU", oemcp => 65001 },
  1151. { name => "pt-MO" },
  1152. { name => "pt-MZ" },
  1153. { name => "pt-PT", lcid => 0x00000816, sabbrevlangname => "PTG" },
  1154. { name => "pt-ST" },
  1155. { name => "pt-TL" },
  1156. ## name => qps-Latn-x-sh", lcid => 0x80000901 },
  1157. ## name => qps-ploc", lcid => 0x80000501 },
  1158. ## name => qps-ploca", lcid => 0x800005fe },
  1159. ## name => qps-plocm", lcid => 0x800009ff },
  1160. { name => "qu", alias => "quz" },
  1161. { name => "qu-BO", alias => "quz-BO" },
  1162. { name => "qu-EC", alias => "quz-EC" },
  1163. { name => "qu-PE", alias => "quz-PE" },
  1164. { name => "quc", lcid => 0x00000086, oemcp => 850, ebcdiccp => 20284, slist => ",", dir => "seed" },
  1165. { name => "quc-Latn", lcid => 0x00007c86, file => "quc", dir => "seed" },
  1166. { name => "quc-Latn-GT", lcid => 0x00000486, file => "quc_GT", dir => "seed" },
  1167. { name => "qut", alias => "quc" },
  1168. { name => "qut-GT", alias => "quc-Latn-GT" },
  1169. { name => "quz", lcid => 0x0000006b, file => "qu", territory => "BO", oemcp => 850, ebcdiccp => 20284, slist => "," },
  1170. { name => "quz-BO", lcid => 0x0000046b, file => "qu_BO" },
  1171. { name => "quz-EC", lcid => 0x0000086b, file => "qu_EC" },
  1172. { name => "quz-Latn", alias => "quz" },
  1173. { name => "quz-Latn-BO", alias => "quz-BO" },
  1174. { name => "quz-Latn-EC", alias => "quz-EC" },
  1175. { name => "quz-Latn-PE", alias => "quz-PE" },
  1176. { name => "quz-PE", lcid => 0x00000c6b, file => "qu_PE" },
  1177. { name => "rm", lcid => 0x00000017, oemcp => 850, ebcdiccp => 20273, sabbrevlangname => "RMC", sopentypelang => "RMS" },
  1178. { name => "rm-CH", lcid => 0x00000417 },
  1179. { name => "rn" },
  1180. { name => "rn-BI" },
  1181. { name => "ro", lcid => 0x00000018, oemcp => 852, ebcdiccp => 20880, sabbrevlangname => "ROM", sopentypelang => "ROM" },
  1182. { name => "ro-MD", lcid => 0x00000818, maccp => 65001, sabbrevlangname => "ROD" },
  1183. { name => "ro-RO", lcid => 0x00000418, group => 2 },
  1184. { name => "rof" },
  1185. { name => "rof-TZ" },
  1186. { name => "ru", lcid => 0x00000019, oemcp => 866 },
  1187. { name => "ru-BY", maccp => 65001 },
  1188. { name => "ru-KG", maccp => 65001 },
  1189. { name => "ru-KZ", maccp => 65001 },
  1190. { name => "ru-MD", lcid => 0x00000819, maccp => 65001, sabbrevlangname => "RUM" },
  1191. { name => "ru-RU", lcid => 0x00000419, group => 5 },
  1192. { name => "ru-UA", maccp => 65001 },
  1193. { name => "rw", lcid => 0x00000087, oemcp => 437, sopentypelang => "RUA" },
  1194. { name => "rw-RW", lcid => 0x00000487 },
  1195. { name => "rwk" },
  1196. { name => "rwk-TZ" },
  1197. { name => "sa", lcid => 0x0000004f, slist => ",", group => 15 },
  1198. { name => "sa-Deva", alias => "sa" },
  1199. { name => "sa-Deva-IN", alias => "sa-IN" },
  1200. { name => "sa-IN", lcid => 0x0000044f },
  1201. { name => "sah", lcid => 0x00000085, oemcp => 866, group => 5, sopentypelang => "YAK" },
  1202. { name => "sah-Cyrl", alias => "sah" },
  1203. { name => "sah-Cyrl-RU", alias => "sah-RU" },
  1204. { name => "sah-RU", lcid => 0x00000485 },
  1205. { name => "saq" },
  1206. { name => "saq-KE" },
  1207. { name => "sat" },
  1208. { name => "sat-Olck" },
  1209. { name => "sat-Olck-IN" },
  1210. { name => "sbp" },
  1211. { name => "sbp-TZ" },
  1212. { name => "sc" },
  1213. { name => "sc-IT" },
  1214. { name => "sd", lcid => 0x00000059, inegnumber => 3, oemcp => 720, sabbrevlangname => "SIP" },
  1215. { name => "sd-Arab", lcid => 0x00007c59, group => 13 },
  1216. { name => "sd-Arab-PK", lcid => 0x00000859 },
  1217. { name => "sd-Deva", inegnumber => 1, slist => ",", oemcp => 65001, group => 15 },
  1218. { name => "sd-Deva-IN", lcid => 0x00000459, sabbrevlangname => "ZZZ" },
  1219. { name => "sd-PK", alias => "sd-Arab-PK" },
  1220. { name => "se", lcid => 0x0000003b, oemcp => 850, ebcdiccp => 20277, sopentypelang => "NSM" },
  1221. { name => "se-FI", lcid => 0x00000c3b, ebcdiccp => 20278, sabbrevlangname => "SMG" },
  1222. { name => "se-NO", lcid => 0x0000043b },
  1223. { name => "se-SE", lcid => 0x0000083b, ebcdiccp => 20278, sabbrevlangname => "SMF" },
  1224. { name => "se-Latn", alias => "se" },
  1225. { name => "se-Latn-FI", alias => "se-FI" },
  1226. { name => "se-Latn-NO", alias => "se-NO" },
  1227. { name => "se-Latn-SE", alias => "se-SE" },
  1228. { name => "seh" },
  1229. { name => "seh-MZ" },
  1230. { name => "ses" },
  1231. { name => "ses-ML" },
  1232. { name => "sg", sopentypelang => "SGO" },
  1233. { name => "sg-CF" },
  1234. { name => "shi" },
  1235. { name => "shi-Latn" },
  1236. { name => "shi-Latn-MA" },
  1237. { name => "shi-Tfng" },
  1238. { name => "shi-Tfng-MA" },
  1239. { name => "si", lcid => 0x0000005b, group => 15, sopentypelang => "SNH" },
  1240. { name => "si-LK", lcid => 0x0000045b },
  1241. { name => "sk", lcid => 0x0000001b, oemcp => 852, ebcdiccp => 20880, group => 2, sabbrevlangname => "SKY", sopentypelang => "SKY" },
  1242. { name => "sk-SK", lcid => 0x0000041b },
  1243. { name => "sl", lcid => 0x00000024, oemcp => 852, ebcdiccp => 20880, group => 2 },
  1244. { name => "sl-SI", lcid => 0x00000424 },
  1245. { name => "sma", lcid => 0x0000783b, sparent => "se", ebcdiccp => 20278, dir => "seed", sabbrevlangname => "SMB", sopentypelang => "SSM" },
  1246. { name => "sma-Latn", alias => "sma" },
  1247. { name => "sma-Latn-NO", alias => "sma-NO" },
  1248. { name => "sma-Latn-SE", alias => "sma-SE" },
  1249. { name => "sma-NO", lcid => 0x0000183b, ebcdiccp => 20277, dir => "seed", sabbrevlangname => "SMA" },
  1250. { name => "sma-SE", lcid => 0x00001c3b, dir => "seed" },
  1251. { name => "smj", lcid => 0x00007c3b, sparent => "se", ebcdiccp => 20278, dir => "seed", sabbrevlangname => "SMK", sopentypelang => "LSM" },
  1252. { name => "smj-Latn", alias => "smj" },
  1253. { name => "smj-Latn-NO", alias => "smj-NO" },
  1254. { name => "smj-Latn-SE", alias => "smj-SE" },
  1255. { name => "smj-NO", lcid => 0x0000103b, ebcdiccp => 20277, dir => "seed", sabbrevlangname => "SMJ" },
  1256. { name => "smj-SE", lcid => 0x0000143b, dir => "seed" },
  1257. { name => "smn", lcid => 0x0000703b, sparent => "se", ebcdiccp => 20278, sopentypelang => "ISM" },
  1258. { name => "smn-FI", lcid => 0x0000243b },
  1259. { name => "smn-Latn", alias => "smn" },
  1260. { name => "smn-Latn-FI", alias => "smn-FI" },
  1261. { name => "sms", lcid => 0x0000743b, sparent => "se", ebcdiccp => 20278, dir => "seed", sopentypelang => "SKS" },
  1262. { name => "sms-FI", lcid => 0x0000203b, dir => "seed" },
  1263. { name => "sms-Latn", alias => "sms" },
  1264. { name => "sms-Latn-FI", alias => "sms-FI" },
  1265. { name => "sn", sopentypelang => "SNA0" },
  1266. { name => "sn-Latn", file => "sn" },
  1267. { name => "sn-Latn-ZW", file => "sn_ZW" },
  1268. { name => "sn-ZW", alias => "sn-Latn-ZW" },
  1269. { name => "so", lcid => 0x00000077, sopentypelang => "SML" },
  1270. { name => "so-DJ" },
  1271. { name => "so-ET" },
  1272. { name => "so-KE" },
  1273. { name => "so-SO", lcid => 0x00000477 },
  1274. { name => "sq", lcid => 0x0000001c, oemcp => 852, ebcdiccp => 20880, group => 2 },
  1275. { name => "sq-AL", lcid => 0x0000041c },
  1276. { name => "sq-MK" },
  1277. { name => "sq-XK" },
  1278. { name => "sr", lcid => 0x00007c1a, sortlocale => "sr-Latn-RS", oemcp => 852, group => 2, sabbrevlangname => "SRB", sopentypelang => "SRB" },
  1279. { name => "sr-Cyrl", lcid => 0x00006c1a, oemcp => 855, ebcdiccp => 21025, group => 5, sabbrevlangname => "SRO" },
  1280. { name => "sr-Cyrl-BA", lcid => 0x00001c1a, sabbrevlangname => "SRN" },
  1281. { name => "sr-Cyrl-ME", lcid => 0x0000301a, sabbrevlangname => "SRQ" },
  1282. { name => "sr-Cyrl-RS", lcid => 0x0000281a },
  1283. { name => "sr-Cyrl-XK" },
  1284. { name => "sr-Latn", lcid => 0x0000701a, sabbrevlangname => "SRM" },
  1285. { name => "sr-Latn-BA", lcid => 0x0000181a, maccp => 10082, ebcdiccp => 870, sabbrevlangname => "SRS" },
  1286. { name => "sr-Latn-ME", lcid => 0x00002c1a, sabbrevlangname => "SRP" },
  1287. { name => "sr-Latn-RS", lcid => 0x0000241a, sabbrevlangname => "SRM" },
  1288. { name => "sr-Latn-XK" },
  1289. ## name => "sr-Cyrl-CS", lcid => 0x00000c1a },
  1290. ## name => "sr-Latn-CS", lcid => 0x0000081a },
  1291. { name => "ss", dir => "seed", sopentypelang => "SWZ" },
  1292. { name => "ss-SZ", dir => "seed" },
  1293. { name => "ss-ZA", dir => "seed" },
  1294. { name => "ssy", dir => "seed" },
  1295. { name => "ssy-ER", dir => "seed" },
  1296. { name => "st", lcid => 0x00000030, dir => "seed" },
  1297. { name => "st-LS", dir => "seed" },
  1298. { name => "st-ZA", lcid => 0x00000430, dir => "seed" },
  1299. { name => "su" },
  1300. { name => "su-Latn" },
  1301. { name => "su-Latn-ID" },
  1302. { name => "sv", lcid => 0x0000001d, oemcp => 850, ebcdiccp => 20278, sabbrevlangname => "SVE", sopentypelang => "SVE" },
  1303. { name => "sv-AX" },
  1304. { name => "sv-FI", lcid => 0x0000081d, sabbrevlangname => "SVF" },
  1305. { name => "sv-SE", lcid => 0x0000041d, sabbrevlangname => "SVE" },
  1306. { name => "sw", lcid => 0x00000041, territory => "KE", oemcp => 437, ebcdiccp => 500, sabbrevlangname => "SWK", sopentypelang => "SWK" },
  1307. { name => "sw-CD" },
  1308. { name => "sw-KE", lcid => 0x00000441 },
  1309. { name => "sw-TZ" },
  1310. { name => "sw-UG" },
  1311. { name => "swc-CD", alias => "sw-CD" },
  1312. { name => "syr", lcid => 0x0000005a, slist => ",", group => 13, dir => "seed" },
  1313. { name => "syr-SY", lcid => 0x0000045a, dir => "seed" },
  1314. { name => "syr-Syrc", alias => "syr" },
  1315. { name => "syr-Syrc-SY", alias => "syr-SY" },
  1316. { name => "ta", lcid => 0x00000049, slist => ",", group => 15, sabbrevlangname => "TAI" },
  1317. { name => "ta-IN", lcid => 0x00000449 },
  1318. { name => "ta-LK", lcid => 0x00000849, sabbrevlangname => "TAM" },
  1319. { name => "ta-MY" },
  1320. { name => "ta-SG" },
  1321. { name => "te", lcid => 0x0000004a, group => 15 },
  1322. { name => "te-IN", lcid => 0x0000044a },
  1323. { name => "teo" },
  1324. { name => "teo-KE" },
  1325. { name => "teo-UG" },
  1326. { name => "tg", lcid => 0x00000028, oemcp => 866, group => 5, sabbrevlangname => "TAJ", sopentypelang => "TAJ" },
  1327. { name => "tg-Cyrl", lcid => 0x00007c28, file => "tg" },
  1328. { name => "tg-Cyrl-TJ", lcid => 0x00000428, file => "tg_TJ" },
  1329. { name => "tg-TJ", alias => "tg-Cyrl-TJ" },
  1330. { name => "th", lcid => 0x0000001e, oemcp => 874, ebcdiccp => 20838, slist => ",", group => 11 },
  1331. { name => "th-TH", lcid => 0x0000041e },
  1332. { name => "ti", lcid => 0x00000073, territory => "ER", sopentypelang => "TGY" },
  1333. { name => "ti-ER", lcid => 0x00000873 },
  1334. { name => "ti-ET", lcid => 0x00000473, sabbrevlangname => "TIE" },
  1335. { name => "tig", dir => "seed", sopentypelang => "TGR" },
  1336. { name => "tig-ER", dir => "seed" },
  1337. { name => "tk", lcid => 0x00000042, oemcp => 852, ebcdiccp => 20880, group => 2, sopentypelang => "TKM" },
  1338. { name => "tk-Latn", alias => "tk" },
  1339. { name => "tk-Latn-TM", alias => "tk-TM" },
  1340. { name => "tk-TM", lcid => 0x00000442 },
  1341. { name => "tn", lcid => 0x00000032, oemcp => 850, dir => "seed", sopentypelang => "TNA" },
  1342. { name => "tn-BW", lcid => 0x00000832, dir => "seed", sabbrevlangname => "TSB" },
  1343. { name => "tn-ZA", lcid => 0x00000432, dir => "seed" },
  1344. { name => "to", sopentypelang => "TGN" },
  1345. { name => "to-TO" },
  1346. { name => "tr", lcid => 0x0000001f, oemcp => 857, ebcdiccp => 20905, group => 6, sabbrevlangname => "TRK", sopentypelang => "TRK" },
  1347. { name => "tr-CY" },
  1348. { name => "tr-TR", lcid => 0x0000041f },
  1349. { name => "ts", lcid => 0x00000031, dir => "seed", sopentypelang => "TSG" },
  1350. { name => "ts-ZA", lcid => 0x00000431, dir => "seed" },
  1351. { name => "tt", lcid => 0x00000044, oemcp => 866, group => 5, sabbrevlangname => "TTT" },
  1352. { name => "tt-Cyrl", alias => "tt" },
  1353. { name => "tt-Cyrl-RU", alias => "tt-RU" },
  1354. { name => "tt-RU", lcid => 0x00000444 },
  1355. { name => "twq" },
  1356. { name => "twq-NE" },
  1357. { name => "tzm", lcid => 0x0000005f, sortlocale => "tzm-Latn-DZ", oemcp => 850, ebcdiccp => 20297, sabbrevlangname => "TZA" },
  1358. { name => "tzm-Latn", lcid => 0x00007c5f, territory => "DZ", file => "tzm" },
  1359. { name => "tzm-Latn-MA", file => "tzm_MA", oemcp => 65001 },
  1360. { name => "tzm-Latn-DZ", lcid => 0x0000085f, file => "tzm" },
  1361. { name => "tzm-MA", alias => "tzm-Latn-MA" },
  1362. ## name => "tzm-Arab", group => 13 },
  1363. ## name => "tzm-Arab-MA", lcid => 0x0000045f },
  1364. ## name => "tzm-Tfng", lcid => 0x0000785f },
  1365. ## name => "tzm-Tfng-MA", lcid => 0x0000105f },
  1366. { name => "ug", lcid => 0x00000080, oemcp => 720, slist => ",", group => 13, sopentypelang => "UYG" },
  1367. { name => "ug-Arab", alias => "ug" },
  1368. { name => "ug-Arab-CN", alias => "ug-CN" },
  1369. { name => "ug-CN", lcid => 0x00000480 },
  1370. { name => "uk", lcid => 0x00000022, oemcp => 866, maccp => 10017, ebcdiccp => 500, group => 5 },
  1371. { name => "uk-UA", lcid => 0x00000422 },
  1372. { name => "ur", lcid => 0x00000020, oemcp => 720 },
  1373. { name => "ur-IN", lcid => 0x00000820, maccp => 65001, sabbrevlangname => "URI" },
  1374. { name => "ur-PK", lcid => 0x00000420, group => 13 },
  1375. { name => "uz", lcid => 0x00000043, oemcp => 857, maccp => 10029, group => 2 },
  1376. { name => "uz-Arab", oemcp => 65001, maccp => 65001 },
  1377. { name => "uz-Arab-AF" },
  1378. { name => "uz-Cyrl", lcid => 0x00007843, oemcp => 866, maccp => 10007, group => 5, sabbrevlangname => "UZC" },
  1379. { name => "uz-Cyrl-UZ", lcid => 0x00000843 },
  1380. { name => "uz-Latn", lcid => 0x00007c43 },
  1381. { name => "uz-Latn-UZ", lcid => 0x00000443 },
  1382. { name => "vai" },
  1383. { name => "vai-Latn" },
  1384. { name => "vai-Latn-LR" },
  1385. { name => "vai-Vaii" },
  1386. { name => "vai-Vaii-LR" },
  1387. { name => "ve", lcid => 0x00000033, dir => "seed", sabbrevlangname => "ZZZ" },
  1388. { name => "ve-ZA", lcid => 0x00000433, dir => "seed" },
  1389. { name => "vi", lcid => 0x0000002a, oemcp => 1258, slist => ",", group => 14, sabbrevlangname => "VIT", sopentypelang => "VIT" },
  1390. { name => "vi-VN", lcid => 0x0000042a },
  1391. { name => "vo", dir => "seed" },
  1392. { name => "vo-001", dir => "seed" },
  1393. { name => "vun" },
  1394. { name => "vun-TZ" },
  1395. { name => "wae" },
  1396. { name => "wae-CH" },
  1397. { name => "wal", dir => "seed" },
  1398. { name => "wal-ET", dir => "seed" },
  1399. { name => "wo", lcid => 0x00000088, oemcp => 850, ebcdiccp => 20297, sopentypelang => "WLF" },
  1400. { name => "wo-Latn", alias => "wo" },
  1401. { name => "wo-Latn-SN", alias => "wo-SN" },
  1402. { name => "wo-SN", lcid => 0x00000488 },
  1403. { name => "x-IV_mathan", lcid => 0x0001007f, alias => "" },
  1404. { name => "xh", lcid => 0x00000034, oemcp => 850, sopentypelang => "XHS" },
  1405. { name => "xh-ZA", lcid => 0x00000434 },
  1406. { name => "xog" },
  1407. { name => "xog-UG" },
  1408. { name => "yav" },
  1409. { name => "yav-CM" },
  1410. { name => "yi", lcid => 0x0000003d, sabbrevlangname => "ZZZ", sopentypelang => "JII" },
  1411. { name => "yi-001", lcid => 0x0000043d },
  1412. { name => "yo", lcid => 0x0000006a, oemcp => 437, sopentypelang => "YBA" },
  1413. { name => "yo-BJ", ebcdiccp => 500 },
  1414. { name => "yo-Latn", alias => "yo" },
  1415. { name => "yo-Latn-NG", alias => "yo-NG" },
  1416. { name => "yo-NG", lcid => 0x0000046a },
  1417. { name => "yrl" },
  1418. { name => "yrl-BR" },
  1419. { name => "yrl-CO" },
  1420. { name => "yrl-VE" },
  1421. { name => "yue" },
  1422. { name => "yue-Hans" },
  1423. { name => "yue-Hans-CN" },
  1424. { name => "yue-Hant" },
  1425. { name => "yue-Hant-HK" },
  1426. { name => "zgh" },
  1427. { name => "zgh-MA", alias => "zgh-Tfng-MA" },
  1428. { name => "zgh-Tfng", file => "zgh" },
  1429. { name => "zgh-Tfng-MA", file => "zgh_MA" },
  1430. { name => "zh", lcid => 0x00007804, ireadinglayout => 2, oemcp => 936, slist => ",", sscripts => "Hani Hans", sabbrevlangname => "CHS", sopentypelang => "ZHS" },
  1431. { name => "zh-CN", lcid => 0x00000804, file => "zh_Hans_CN", sparent => "zh-Hans" },
  1432. { name => "zh-CN_phoneb", lcid => 0x00050804, alias => "zh-CN" },
  1433. { name => "zh-CN_stroke", lcid => 0x00020804, alias => "zh-CN" },
  1434. { name => "zh-Hans", lcid => 0x00000004, group => 10 },
  1435. { name => "zh-Hans-CN", alias => "zh-CN" },
  1436. { name => "zh-Hans-CN-u-co-phonebk", alias => "zh-CN_phoneb" },
  1437. { name => "zh-Hans-CN-u-co-stroke", alias => "zh-CN_stroke" },
  1438. { name => "zh-Hans-HK", slist => ";" },
  1439. { name => "zh-Hans-MO", slist => ";" },
  1440. { name => "zh-Hans-SG", alias => "zh-SG" },
  1441. { name => "zh-Hans-SG-u-co-phonebk", alias => "zh-SG_phoneb" },
  1442. { name => "zh-Hans-SG-u-co-stroke", alias => "zh-SG_stroke" },
  1443. { name => "zh-Hant", lcid => 0x00007c04, sortlocale => "zh-HK", ireadinglayout => 2, oemcp => 950, slist => ",", sscripts => "Hani Hant", group => 9, sabbrevlangname => "CHT", sopentypelang => "ZHH" },
  1444. { name => "zh-Hant-HK", alias => "zh-HK" },
  1445. { name => "zh-Hant-HK-u-co-unihan", alias => "zh-HK_radstr" },
  1446. { name => "zh-Hant-MO", alias => "zh-MO" },
  1447. { name => "zh-Hant-MO-u-co-stroke", alias => "zh-MO_stroke" },
  1448. { name => "zh-Hant-MO-u-co-unihan", alias => "zh-MO_radstr" },
  1449. { name => "zh-Hant-TW", alias => "zh-TW" },
  1450. { name => "zh-Hant-TW-u-co-phonetic", alias => "zh-TW_pronun" },
  1451. { name => "zh-Hant-TW-u-co-unihan", alias => "zh-TW_radstr" },
  1452. { name => "zh-HK", lcid => 0x00000c04, file => "zh_Hant_HK", sparent => "zh-Hant", sabbrevlangname => "ZHH" },
  1453. { name => "zh-HK_radstr", lcid => 0x00040c04, alias => "zh-HK" },
  1454. { name => "zh-MO", lcid => 0x00001404, file => "zh_Hant_MO", sparent => "zh-Hant", sabbrevlangname => "ZHM", sopentypelang => "ZHT" },
  1455. { name => "zh-MO_radstr", lcid => 0x00041404, alias => "zh-MO" },
  1456. { name => "zh-MO_stroke", lcid => 0x00021404, alias => "zh-MO" },
  1457. { name => "zh-SG", lcid => 0x00001004, file => "zh_Hans_SG", sparent => "zh-Hans", sabbrevlangname => "ZHI" },
  1458. { name => "zh-SG_phoneb", lcid => 0x00051004, alias => "zh-SG" },
  1459. { name => "zh-SG_stroke", lcid => 0x00021004, alias => "zh-SG" },
  1460. { name => "zh-TW", lcid => 0x00000404, file => "zh_Hant_TW", sparent => "zh-Hant", sopentypelang => "ZHT" },
  1461. { name => "zh-TW_pronun", lcid => 0x00030404, alias => "zh-TW" },
  1462. { name => "zh-TW_radstr", lcid => 0x00040404, alias => "zh-TW" },
  1463. { name => "zu", lcid => 0x00000035, oemcp => 850 },
  1464. { name => "zu-ZA", lcid => 0x00000435 },
  1465. );
  1466. my @calendars =
  1467. (
  1468. { id => 1, name => "Gregorian", itwodigityearmax => 2049 },
  1469. { id => 2, type => "gregorian", locale => "en-US", itwodigityearmax => 2049 },
  1470. { id => 3, type => "japanese", locale => "ja-JP", eras => [ 232..236 ] },
  1471. { id => 4, type => "roc", locale => "zh-TW", eras => [ 1 ] },
  1472. { id => 5, type => "dangi", locale => "ko-KR", eras => [ 0 ] },
  1473. { id => 6, type => "islamic", locale => "ar-SA", itwodigityearmax => 1451 },
  1474. { id => 7, type => "buddhist", locale => "th-TH", eras => [ 0 ] },
  1475. { id => 8, type => "hebrew", locale => "he-IL", itwodigityearmax => 5810 },
  1476. { id => 9, type => "gregorian", locale => "fr-FR", itwodigityearmax => 2049 },
  1477. { id => 10, type => "gregorian", locale => "ar-SA", itwodigityearmax => 2049 },
  1478. { id => 11, type => "gregorian", locale => "ar-SA", itwodigityearmax => 2049 },
  1479. { id => 12, type => "gregorian", locale => "ar-SA", itwodigityearmax => 2049 },
  1480. { id => 13, name => "Julian", locale => "en-US", itwodigityearmax => 2049 },
  1481. { id => 14, name => "Japanese Lunisolar" },
  1482. { id => 15, name => "Chinese Lunisolar" },
  1483. { id => 16, name => "Saka" },
  1484. { id => 17, name => "Lunar ETO Chinese" },
  1485. { id => 18, name => "Lunar ETO Korean" },
  1486. { id => 19, name => "Lunar ETO Rokuyou" },
  1487. { id => 20, name => "Korean Lunisolar" },
  1488. { id => 21, name => "Taiwan Lunisolar" },
  1489. { id => 22, type => "persian", locale => "prs-AF", itwodigityearmax => 1429 },
  1490. { id => 23, type => "islamic-umalqura", locale => "ar-SA", itwodigityearmax => 1451 },
  1491. );
  1492. my @geoids =
  1493. (
  1494. { id => 2, name => "AG" }, # Antigua and Barbuda
  1495. { id => 3, name => "AF" }, # Afghanistan
  1496. { id => 4, name => "DZ" }, # Algeria
  1497. { id => 5, name => "AZ" }, # Azerbaijan
  1498. { id => 6, name => "AL" }, # Albania
  1499. { id => 7, name => "AM" }, # Armenia
  1500. { id => 8, name => "AD" }, # Andorra
  1501. { id => 9, name => "AO" }, # Angola
  1502. { id => 10, name => "AS" }, # American Samoa
  1503. { id => 11, name => "AR" }, # Argentina
  1504. { id => 12, name => "AU" }, # Australia
  1505. { id => 14, name => "AT" }, # Austria
  1506. { id => 17, name => "BH" }, # Bahrain
  1507. { id => 18, name => "BB" }, # Barbados
  1508. { id => 19, name => "BW" }, # Botswana
  1509. { id => 20, name => "BM" }, # Bermuda
  1510. { id => 21, name => "BE" }, # Belgium
  1511. { id => 22, name => "BS" }, # Bahamas, The
  1512. { id => 23, name => "BD" }, # Bangladesh
  1513. { id => 24, name => "BZ" }, # Belize
  1514. { id => 25, name => "BA" }, # Bosnia and Herzegovina
  1515. { id => 26, name => "BO" }, # Bolivia
  1516. { id => 27, name => "MM" }, # Myanmar
  1517. { id => 28, name => "BJ" }, # Benin
  1518. { id => 29, name => "BY" }, # Belarus
  1519. { id => 30, name => "SB" }, # Solomon Islands
  1520. { id => 32, name => "BR" }, # Brazil
  1521. { id => 34, name => "BT" }, # Bhutan
  1522. { id => 35, name => "BG" }, # Bulgaria
  1523. { id => 37, name => "BN" }, # Brunei
  1524. { id => 38, name => "BI" }, # Burundi
  1525. { id => 39, name => "CA" }, # Canada
  1526. { id => 40, name => "KH" }, # Cambodia
  1527. { id => 41, name => "TD" }, # Chad
  1528. { id => 42, name => "LK" }, # Sri Lanka
  1529. { id => 43, name => "CG" }, # Congo
  1530. { id => 44, name => "CD" }, # Congo (DRC)
  1531. { id => 45, name => "CN" }, # China
  1532. { id => 46, name => "CL" }, # Chile
  1533. { id => 49, name => "CM" }, # Cameroon
  1534. { id => 50, name => "KM" }, # Comoros
  1535. { id => 51, name => "CO" }, # Colombia
  1536. { id => 54, name => "CR" }, # Costa Rica
  1537. { id => 55, name => "CF" }, # Central African Republic
  1538. { id => 56, name => "CU" }, # Cuba
  1539. { id => 57, name => "CV" }, # Cape Verde
  1540. { id => 59, name => "CY" }, # Cyprus
  1541. { id => 61, name => "DK" }, # Denmark
  1542. { id => 62, name => "DJ" }, # Djibouti
  1543. { id => 63, name => "DM" }, # Dominica
  1544. { id => 65, name => "DO" }, # Dominican Republic
  1545. { id => 66, name => "EC" }, # Ecuador
  1546. { id => 67, name => "EG" }, # Egypt
  1547. { id => 68, name => "IE" }, # Ireland
  1548. { id => 69, name => "GQ" }, # Equatorial Guinea
  1549. { id => 70, name => "EE" }, # Estonia
  1550. { id => 71, name => "ER" }, # Eritrea
  1551. { id => 72, name => "SV" }, # El Salvador
  1552. { id => 73, name => "ET" }, # Ethiopia
  1553. { id => 75, name => "CZ" }, # Czech Republic
  1554. { id => 77, name => "FI" }, # Finland
  1555. { id => 78, name => "FJ" }, # Fiji Islands
  1556. { id => 80, name => "FM" }, # Micronesia
  1557. { id => 81, name => "FO" }, # Faroe Islands
  1558. { id => 84, name => "FR" }, # France
  1559. { id => 86, name => "GM" }, # Gambia, The
  1560. { id => 87, name => "GA" }, # Gabon
  1561. { id => 88, name => "GE" }, # Georgia
  1562. { id => 89, name => "GH" }, # Ghana
  1563. { id => 90, name => "GI" }, # Gibraltar
  1564. { id => 91, name => "GD" }, # Grenada
  1565. { id => 93, name => "GL" }, # Greenland
  1566. { id => 94, name => "DE" }, # Germany
  1567. { id => 98, name => "GR" }, # Greece
  1568. { id => 99, name => "GT" }, # Guatemala
  1569. { id => 100, name => "GN" }, # Guinea
  1570. { id => 101, name => "GY" }, # Guyana
  1571. { id => 103, name => "HT" }, # Haiti
  1572. { id => 104, name => "HK" }, # Hong Kong S.A.R.
  1573. { id => 106, name => "HN" }, # Honduras
  1574. { id => 108, name => "HR" }, # Croatia
  1575. { id => 109, name => "HU" }, # Hungary
  1576. { id => 110, name => "IS" }, # Iceland
  1577. { id => 111, name => "ID" }, # Indonesia
  1578. { id => 113, name => "IN" }, # India
  1579. { id => 114, name => "IO" }, # British Indian Ocean Territory
  1580. { id => 116, name => "IR" }, # Iran
  1581. { id => 117, name => "IL" }, # Israel
  1582. { id => 118, name => "IT" }, # Italy
  1583. { id => 119, name => "CI" }, # Côte d'Ivoire
  1584. { id => 121, name => "IQ" }, # Iraq
  1585. { id => 122, name => "JP" }, # Japan
  1586. { id => 124, name => "JM" }, # Jamaica
  1587. { id => 125, name => "SJ" }, # Jan Mayen
  1588. { id => 126, name => "JO" }, # Jordan
  1589. { id => 127, parent => "UM" }, # Johnston Atoll
  1590. { id => 129, name => "KE" }, # Kenya
  1591. { id => 130, name => "KG" }, # Kyrgyzstan
  1592. { id => 131, name => "KP" }, # North Korea
  1593. { id => 133, name => "KI" }, # Kiribati
  1594. { id => 134, name => "KR" }, # Korea
  1595. { id => 136, name => "KW" }, # Kuwait
  1596. { id => 137, name => "KZ" }, # Kazakhstan
  1597. { id => 138, name => "LA" }, # Laos
  1598. { id => 139, name => "LB" }, # Lebanon
  1599. { id => 140, name => "LV" }, # Latvia
  1600. { id => 141, name => "LT" }, # Lithuania
  1601. { id => 142, name => "LR" }, # Liberia
  1602. { id => 143, name => "SK" }, # Slovakia
  1603. { id => 145, name => "LI" }, # Liechtenstein
  1604. { id => 146, name => "LS" }, # Lesotho
  1605. { id => 147, name => "LU" }, # Luxembourg
  1606. { id => 148, name => "LY" }, # Libya
  1607. { id => 149, name => "MG" }, # Madagascar
  1608. { id => 151, name => "MO" }, # Macao S.A.R.
  1609. { id => 152, name => "MD" }, # Moldova
  1610. { id => 154, name => "MN" }, # Mongolia
  1611. { id => 156, name => "MW" }, # Malawi
  1612. { id => 157, name => "ML" }, # Mali
  1613. { id => 158, name => "MC" }, # Monaco
  1614. { id => 159, name => "MA" }, # Morocco
  1615. { id => 160, name => "MU" }, # Mauritius
  1616. { id => 162, name => "MR" }, # Mauritania
  1617. { id => 163, name => "MT" }, # Malta
  1618. { id => 164, name => "OM" }, # Oman
  1619. { id => 165, name => "MV" }, # Maldives
  1620. { id => 166, name => "MX" }, # Mexico
  1621. { id => 167, name => "MY" }, # Malaysia
  1622. { id => 168, name => "MZ" }, # Mozambique
  1623. { id => 173, name => "NE" }, # Niger
  1624. { id => 174, name => "VU" }, # Vanuatu
  1625. { id => 175, name => "NG" }, # Nigeria
  1626. { id => 176, name => "NL" }, # Netherlands
  1627. { id => 177, name => "NO" }, # Norway
  1628. { id => 178, name => "NP" }, # Nepal
  1629. { id => 180, name => "NR" }, # Nauru
  1630. { id => 181, name => "SR" }, # Suriname
  1631. { id => 182, name => "NI" }, # Nicaragua
  1632. { id => 183, name => "NZ" }, # New Zealand
  1633. { id => 184, name => "PS" }, # Palestinian Authority
  1634. { id => 185, name => "PY" }, # Paraguay
  1635. { id => 187, name => "PE" }, # Peru
  1636. { id => 190, name => "PK" }, # Pakistan
  1637. { id => 191, name => "PL" }, # Poland
  1638. { id => 192, name => "PA" }, # Panama
  1639. { id => 193, name => "PT" }, # Portugal
  1640. { id => 194, name => "PG" }, # Papua New Guinea
  1641. { id => 195, name => "PW" }, # Palau
  1642. { id => 196, name => "GW" }, # Guinea-Bissau
  1643. { id => 197, name => "QA" }, # Qatar
  1644. { id => 198, name => "RE" }, # Reunion
  1645. { id => 199, name => "MH" }, # Marshall Islands
  1646. { id => 200, name => "RO" }, # Romania
  1647. { id => 201, name => "PH" }, # Philippines
  1648. { id => 202, name => "PR" }, # Puerto Rico
  1649. { id => 203, name => "RU" }, # Russia
  1650. { id => 204, name => "RW" }, # Rwanda
  1651. { id => 205, name => "SA" }, # Saudi Arabia
  1652. { id => 206, name => "PM" }, # St. Pierre and Miquelon
  1653. { id => 207, name => "KN" }, # St. Kitts and Nevis
  1654. { id => 208, name => "SC" }, # Seychelles
  1655. { id => 209, name => "ZA" }, # South Africa
  1656. { id => 210, name => "SN" }, # Senegal
  1657. { id => 212, name => "SI" }, # Slovenia
  1658. { id => 213, name => "SL" }, # Sierra Leone
  1659. { id => 214, name => "SM" }, # San Marino
  1660. { id => 215, name => "SG" }, # Singapore
  1661. { id => 216, name => "SO" }, # Somalia
  1662. { id => 217, name => "ES" }, # Spain
  1663. { id => 218, name => "LC" }, # St. Lucia
  1664. { id => 219, name => "SD" }, # Sudan
  1665. { id => 220, name => "SJ" }, # Svalbard
  1666. { id => 221, name => "SE" }, # Sweden
  1667. { id => 222, name => "SY" }, # Syria
  1668. { id => 223, name => "CH" }, # Switzerland
  1669. { id => 224, name => "AE" }, # United Arab Emirates
  1670. { id => 225, name => "TT" }, # Trinidad and Tobago
  1671. { id => 227, name => "TH" }, # Thailand
  1672. { id => 228, name => "TJ" }, # Tajikistan
  1673. { id => 231, name => "TO" }, # Tonga
  1674. { id => 232, name => "TG" }, # Togo
  1675. { id => 233, name => "ST" }, # São Tomé and Príncipe
  1676. { id => 234, name => "TN" }, # Tunisia
  1677. { id => 235, name => "TR" }, # Turkey
  1678. { id => 236, name => "TV" }, # Tuvalu
  1679. { id => 237, name => "TW" }, # Taiwan
  1680. { id => 238, name => "TM" }, # Turkmenistan
  1681. { id => 239, name => "TZ" }, # Tanzania
  1682. { id => 240, name => "UG" }, # Uganda
  1683. { id => 241, name => "UA" }, # Ukraine
  1684. { id => 242, name => "GB" }, # United Kingdom
  1685. { id => 244, name => "US" }, # United States
  1686. { id => 245, name => "BF" }, # Burkina Faso
  1687. { id => 246, name => "UY" }, # Uruguay
  1688. { id => 247, name => "UZ" }, # Uzbekistan
  1689. { id => 248, name => "VC" }, # St. Vincent and the Grenadines
  1690. { id => 249, name => "VE" }, # Bolivarian Republic of Venezuela
  1691. { id => 251, name => "VN" }, # Vietnam
  1692. { id => 252, name => "VI" }, # Virgin Islands
  1693. { id => 253, name => "VA" }, # Vatican City
  1694. { id => 254, name => "NA" }, # Namibia
  1695. { id => 257, name => "EH" }, # Western Sahara (disputed)
  1696. { id => 258, parent => "UM" }, # Wake Island
  1697. { id => 259, name => "WS" }, # Samoa
  1698. { id => 260, name => "SZ" }, # Swaziland
  1699. { id => 261, name => "YE" }, # Yemen
  1700. { id => 263, name => "ZM" }, # Zambia
  1701. { id => 264, name => "ZW" }, # Zimbabwe
  1702. { id => 269, name => "CS" }, # Serbia and Montenegro (Former)
  1703. { id => 270, name => "ME" }, # Montenegro
  1704. { id => 271, name => "RS" }, # Serbia
  1705. { id => 273, name => "CW" }, # Curaçao
  1706. { id => 276, name => "SS" }, # South Sudan
  1707. { id => 300, name => "AI" }, # Anguilla
  1708. { id => 301, name => "AQ" }, # Antarctica
  1709. { id => 302, name => "AW" }, # Aruba
  1710. { id => 303, parent => "SH" }, # Ascension Island
  1711. { id => 304, parent => "053" }, # Ashmore and Cartier Islands
  1712. { id => 305, parent => "UM" }, # Baker Island
  1713. { id => 306, name => "BV" }, # Bouvet Island
  1714. { id => 307, name => "KY" }, # Cayman Islands
  1715. { id => 308, name => "830", parent => "155" }, # Channel Islands
  1716. { id => 309, name => "CX" }, # Christmas Island
  1717. { id => 310, parent => "009" }, # Clipperton Island
  1718. { id => 311, name => "CC" }, # Cocos (Keeling) Islands
  1719. { id => 312, name => "CK" }, # Cook Islands
  1720. { id => 313, parent => "053" }, # Coral Sea Islands
  1721. { id => 314, parent => "IO" }, # Diego Garcia
  1722. { id => 315, name => "FK" }, # Falkland Islands (Islas Malvinas)
  1723. { id => 317, name => "GF" }, # French Guiana
  1724. { id => 318, name => "PF" }, # French Polynesia
  1725. { id => 319, name => "TF" }, # French Southern and Antarctic Lands
  1726. { id => 321, name => "GP" }, # Guadeloupe
  1727. { id => 322, name => "GU" }, # Guam
  1728. { id => 323 }, # Guantanamo Bay
  1729. { id => 324, name => "GG" }, # Guernsey
  1730. { id => 325, name => "HM" }, # Heard Island and McDonald Islands
  1731. { id => 326, parent => "UM" }, # Howland Island
  1732. { id => 327, parent => "UM" }, # Jarvis Island
  1733. { id => 328, name => "JE" }, # Jersey
  1734. { id => 329, parent => "UM" }, # Kingman Reef
  1735. { id => 330, name => "MQ" }, # Martinique
  1736. { id => 331, name => "YT" }, # Mayotte
  1737. { id => 332, name => "MS" }, # Montserrat
  1738. { id => 333, name => "AN", region => 1 }, # Netherlands Antilles (Former)
  1739. { id => 334, name => "NC" }, # New Caledonia
  1740. { id => 335, name => "NU" }, # Niue
  1741. { id => 336, name => "NF" }, # Norfolk Island
  1742. { id => 337, name => "MP" }, # Northern Mariana Islands
  1743. { id => 338, parent => "UM" }, # Palmyra Atoll
  1744. { id => 339, name => "PN" }, # Pitcairn Islands
  1745. { id => 340, parent => "MP" }, # Rota Island
  1746. { id => 341, parent => "MP" }, # Saipan
  1747. { id => 342, name => "GS" }, # South Georgia and the South Sandwich Islands
  1748. { id => 343, name => "SH" }, # St. Helena
  1749. { id => 346, parent => "MP" }, # Tinian Island
  1750. { id => 347, name => "TK" }, # Tokelau
  1751. { id => 348, parent => "SH" }, # Tristan da Cunha
  1752. { id => 349, name => "TC" }, # Turks and Caicos Islands
  1753. { id => 351, name => "VG" }, # Virgin Islands, British
  1754. { id => 352, name => "WF" }, # Wallis and Futuna
  1755. { id => 742, name => "002" }, # Africa
  1756. { id => 2129, name => "142" }, # Asia
  1757. { id => 10541, name => "150" }, # Europe
  1758. { id => 15126, name => "IM" }, # Man, Isle of
  1759. { id => 19618, name => "MK" }, # Macedonia, Former Yugoslav Republic of
  1760. { id => 20900, name => "054" }, # Melanesia
  1761. { id => 21206, name => "057" }, # Micronesia
  1762. { id => 21242, parent => "UM" }, # Midway Islands
  1763. { id => 23581, name => "021" }, # Northern America
  1764. { id => 26286, name => "061" }, # Polynesia
  1765. { id => 27082, name => "013" }, # Central America
  1766. { id => 27114, name => "009" }, # Oceania
  1767. { id => 30967, name => "SX" }, # Sint Maarten (Dutch part)
  1768. { id => 31396, name => "005" }, # South America
  1769. { id => 31706, name => "MF" }, # Saint Martin (French part)
  1770. { id => 39070, name => "001" }, # World
  1771. { id => 42483, name => "011" }, # Western Africa
  1772. { id => 42484, name => "017" }, # Middle Africa
  1773. { id => 42487, name => "015" }, # Northern Africa
  1774. { id => 47590, name => "143" }, # Central Asia
  1775. { id => 47599, name => "035" }, # South-Eastern Asia
  1776. { id => 47600, name => "030" }, # Eastern Asia
  1777. { id => 47603, name => "014" }, # Eastern Africa
  1778. { id => 47609, name => "151" }, # Eastern Europe
  1779. { id => 47610, name => "039" }, # Southern Europe
  1780. { id => 47611, name => "145" }, # Middle East
  1781. { id => 47614, name => "034" }, # Southern Asia
  1782. { id => 7299303, name => "TL" }, # Democratic Republic of Timor-Leste
  1783. { id => 9914689, name => "XK" }, # Kosovo
  1784. { id => 10026358, name => "019" }, # Americas
  1785. { id => 10028789, name => "AX" }, # Åland Islands
  1786. { id => 10039880, name => "029", sintlsymbol => "XCD" }, # Caribbean
  1787. { id => 10039882, name => "154" }, # Northern Europe
  1788. { id => 10039883, name => "018" }, # Southern Africa
  1789. { id => 10210824, name => "155" }, # Western Europe
  1790. { id => 10210825, name => "053" }, # Australia and New Zealand
  1791. { id => 161832015, name => "BL" }, # Saint Barthélemy
  1792. { id => 161832256, name => "UM" }, # U.S. Minor Outlying Islands
  1793. { id => 161832257, name => "419", parent => "019" }, # Latin America and the Caribbean
  1794. { id => 161832258, name => "BQ" }, # Bonaire, Sint Eustatius and Saba
  1795. );
  1796. my @cp2uni = ();
  1797. my @glyph2uni = ();
  1798. my @lead_bytes = ();
  1799. my @uni2cp = ();
  1800. my @tolower_table = ();
  1801. my @toupper_table = ();
  1802. my @digitmap_table = ();
  1803. my @category_table = ();
  1804. my @initial_joining_table = ();
  1805. my @direction_table = ();
  1806. my @decomp_table = ();
  1807. my @combining_class_table = ();
  1808. my @decomp_compat_table = ();
  1809. my @comp_exclusions = ();
  1810. my @idna_decomp_table = ();
  1811. my @idna_disallowed = ();
  1812. my %registry_keys;
  1813. my $default_char;
  1814. my $default_wchar;
  1815. my %joining_forms =
  1816. (
  1817. "isolated" => [],
  1818. "final" => [],
  1819. "initial" => [],
  1820. "medial" => []
  1821. );
  1822. sub to_utf16(@)
  1823. {
  1824. my @ret;
  1825. foreach my $ch (@_)
  1826. {
  1827. if ($ch < 0x10000)
  1828. {
  1829. push @ret, $ch;
  1830. }
  1831. else
  1832. {
  1833. my $val = $ch - 0x10000;
  1834. push @ret, 0xd800 | ($val >> 10), 0xdc00 | ($val & 0x3ff);
  1835. }
  1836. }
  1837. return @ret;
  1838. }
  1839. ################################################################
  1840. # fetch a unicode.org file and open it
  1841. sub open_data_file($$)
  1842. {
  1843. my ($base, $name) = @_;
  1844. my $cache = ($ENV{XDG_CACHE_HOME} || "$ENV{HOME}/.cache") . "/wine";
  1845. (my $dir = "$cache/$name") =~ s/\/[^\/]+$//;
  1846. my $suffix = ($base =~ /\/\Q$UNIVERSION\E/) ? "-$UNIVERSION" : "";
  1847. local *FILE;
  1848. if ($base =~ /.*\/([^\/]+)\.zip$/)
  1849. {
  1850. my $zip = "$1$suffix.zip";
  1851. unless (-f "$cache/$zip")
  1852. {
  1853. system "mkdir", "-p", $cache;
  1854. print "Fetching $base...\n";
  1855. !system "wget", "-q", "-O", "$cache/$zip", $base or die "cannot fetch $base";
  1856. }
  1857. open FILE, "-|", "unzip", "-p", "$cache/$zip", $name or die "cannot extract $name from $zip";
  1858. }
  1859. else
  1860. {
  1861. (my $dest = "$cache/$name") =~ s/(.*)(\.[^\/.]+)$/$1$suffix$2/;
  1862. unless (-f $dest)
  1863. {
  1864. system "mkdir", "-p", $dir;
  1865. print "Fetching $base/$name...\n";
  1866. !system "wget", "-q", "-O", $dest, "$base/$name" or die "cannot fetch $base/$name";
  1867. }
  1868. open FILE, "<$dest" or die "cannot open $dest";
  1869. }
  1870. return *FILE;
  1871. }
  1872. ################################################################
  1873. # load a unicode.org file as XML data
  1874. sub load_xml_data_file($$)
  1875. {
  1876. my ($base, $name) = @_;
  1877. my $FILE = open_data_file( $base, $name );
  1878. my $xml = XML::LibXML->load_xml( IO => $FILE );
  1879. close FILE;
  1880. return $xml;
  1881. }
  1882. ################################################################
  1883. # recursively get the decomposition for a character
  1884. sub get_decomposition($$);
  1885. sub get_decomposition($$)
  1886. {
  1887. my ($char, $table) = @_;
  1888. my @ret;
  1889. return $char unless defined $table->[$char];
  1890. foreach my $ch (@{$table->[$char]})
  1891. {
  1892. push @ret, get_decomposition( $ch, $table );
  1893. }
  1894. return @ret;
  1895. }
  1896. ################################################################
  1897. # get the composition that results in a given character
  1898. sub get_composition($$)
  1899. {
  1900. my ($ch, $compat) = @_;
  1901. return () unless defined $decomp_table[$ch]; # no decomposition
  1902. my @ret = @{$decomp_table[$ch]};
  1903. return () if @ret < 2; # singleton decomposition
  1904. return () if $comp_exclusions[$ch]; # composition exclusion
  1905. return () if $combining_class_table[$ch]; # non-starter
  1906. return () if $combining_class_table[$ret[0]]; # first char is non-starter
  1907. return () if $compat == 1 && !defined $decomp_table[$ret[0]] &&
  1908. defined $decomp_compat_table[$ret[0]]; # first char has compat decomposition
  1909. return () if $compat == 2 && !defined $decomp_table[$ret[0]] &&
  1910. defined $idna_decomp_table[$ret[0]]; # first char has IDNA decomposition
  1911. return () if $compat == 2 && defined $idna_decomp_table[$ret[0]] &&
  1912. defined $idna_decomp_table[$idna_decomp_table[$ret[0]]->[0]]; # first char's decomposition has IDNA decomposition
  1913. return () if $compat == 2 && defined $idna_decomp_table[$ret[1]]; # second char has IDNA decomposition
  1914. return @ret;
  1915. }
  1916. ################################################################
  1917. # recursively build decompositions
  1918. sub build_decompositions(@)
  1919. {
  1920. my @src = @_;
  1921. my @dst;
  1922. for (my $i = 0; $i < @src; $i++)
  1923. {
  1924. next unless defined $src[$i];
  1925. my @decomp = to_utf16( get_decomposition( $i, \@src ));
  1926. $dst[$i] = \@decomp;
  1927. }
  1928. return @dst;
  1929. }
  1930. ################################################################
  1931. # compose Hangul sequences
  1932. sub compose_hangul(@)
  1933. {
  1934. my $SBASE = 0xac00;
  1935. my $LBASE = 0x1100;
  1936. my $VBASE = 0x1161;
  1937. my $TBASE = 0x11a7;
  1938. my $LCOUNT = 19;
  1939. my $VCOUNT = 21;
  1940. my $TCOUNT = 28;
  1941. my $NCOUNT = $VCOUNT * $TCOUNT;
  1942. my $SCOUNT = $LCOUNT * $NCOUNT;
  1943. my @seq = @_;
  1944. my @ret;
  1945. my $i;
  1946. for ($i = 0; $i < @seq; $i++)
  1947. {
  1948. my $ch = $seq[$i];
  1949. if ($ch >= $LBASE && $ch < $LBASE + $LCOUNT && $i < @seq - 1 &&
  1950. $seq[$i+1] >= $VBASE && $seq[$i+1] < $VBASE + $VCOUNT)
  1951. {
  1952. $ch = $SBASE + (($seq[$i] - $LBASE) * $VCOUNT + ($seq[$i+1] - $VBASE)) * $TCOUNT;
  1953. $i++;
  1954. }
  1955. if ($ch >= $SBASE && $ch < $SBASE + $SCOUNT && !(($ch - $SBASE) % $TCOUNT) && $i < @seq - 1 &&
  1956. $seq[$i+1] > $TBASE && $seq[$i+1] < $TBASE + $TCOUNT)
  1957. {
  1958. $ch += $seq[$i+1] - $TBASE;
  1959. $i++;
  1960. }
  1961. push @ret, $ch;
  1962. }
  1963. return @ret;
  1964. }
  1965. ################################################################
  1966. # remove linguistic-only mappings from the case table
  1967. sub remove_linguistic_mappings($$)
  1968. {
  1969. my ($upper, $lower) = @_;
  1970. # remove case mappings that don't round-trip
  1971. for (my $i = 0; $i < @{$upper}; $i++)
  1972. {
  1973. next unless defined ${$upper}[$i];
  1974. my $ch = ${$upper}[$i];
  1975. ${$upper}[$i] = undef unless defined ${$lower}[$ch] && ${$lower}[$ch] == $i;
  1976. }
  1977. for (my $i = 0; $i < @{$lower}; $i++)
  1978. {
  1979. next unless defined ${$lower}[$i];
  1980. my $ch = ${$lower}[$i];
  1981. ${$lower}[$i] = undef unless defined ${$upper}[$ch] && ${$upper}[$ch] == $i;
  1982. }
  1983. }
  1984. ################################################################
  1985. # read in the Unicode database files
  1986. sub load_data()
  1987. {
  1988. my $start;
  1989. # now build mappings from the decomposition field of the Unicode database
  1990. my $UNICODE_DATA = open_data_file( $UNIDATA, "UnicodeData.txt" );
  1991. while (<$UNICODE_DATA>)
  1992. {
  1993. # Decode the fields ...
  1994. my ($code, $name, $cat, $comb, $bidi,
  1995. $decomp, $dec, $dig, $num, $mirror,
  1996. $oldname, $comment, $upper, $lower, $title) = split /;/;
  1997. my $src = hex $code;
  1998. die "unknown category $cat" unless defined $categories{$cat};
  1999. die "unknown directionality $bidi" unless defined $directions{$bidi};
  2000. $category_table[$src] = $categories{$cat};
  2001. $direction_table[$src] = $bidi;
  2002. if ($cat eq "Mn" || $cat eq "Me" || $cat eq "Cf")
  2003. {
  2004. $initial_joining_table[$src] = $joining_types{"T"};
  2005. }
  2006. else
  2007. {
  2008. $initial_joining_table[$src] = $joining_types{"U"};
  2009. }
  2010. if ($lower ne "")
  2011. {
  2012. $tolower_table[$src] = hex $lower;
  2013. }
  2014. if ($upper ne "")
  2015. {
  2016. $toupper_table[$src] = hex $upper;
  2017. }
  2018. if ($dec ne "")
  2019. {
  2020. $category_table[$src] |= $ctype{"digit"};
  2021. }
  2022. if ($dig ne "")
  2023. {
  2024. $digitmap_table[$src] = ord $dig;
  2025. }
  2026. $combining_class_table[$src] = ($cat ne "Co") ? $comb : 0x100; # Private Use
  2027. $category_table[$src] |= $ctype{"nonspacing"} if $bidi eq "NSM";
  2028. $category_table[$src] |= $ctype{"diacritic"} if $name =~ /^(COMBINING)|(MODIFIER LETTER)\W/;
  2029. $category_table[$src] |= $ctype{"vowelmark"} if $name =~ /\sVOWEL/ || $oldname =~ /\sVOWEL/;
  2030. $category_table[$src] |= $ctype{"halfwidth"} if $name =~ /^HALFWIDTH\s/;
  2031. $category_table[$src] |= $ctype{"fullwidth"} if $name =~ /^FULLWIDTH\s/;
  2032. $category_table[$src] |= $ctype{"hiragana"} if $name =~ /(HIRAGANA)|(\WKANA\W)/;
  2033. $category_table[$src] |= $ctype{"katakana"} if $name =~ /(KATAKANA)|(\WKANA\W)/;
  2034. $category_table[$src] |= $ctype{"ideograph"} if $name =~ /^<CJK Ideograph/;
  2035. $category_table[$src] |= $ctype{"ideograph"} if $name =~ /^CJK COMPATIBILITY IDEOGRAPH/;
  2036. $category_table[$src] |= $ctype{"ideograph"} if $name =~ /^HANGZHOU/;
  2037. $category_table[$src] |= $ctype{"highsurrogate"} if $name =~ /High Surrogate/;
  2038. $category_table[$src] |= $ctype{"lowsurrogate"} if $name =~ /Low Surrogate/;
  2039. # copy the category and direction for everything between First/Last pairs
  2040. if ($name =~ /, First>/) { $start = $src; }
  2041. if ($name =~ /, Last>/)
  2042. {
  2043. while ($start < $src)
  2044. {
  2045. $category_table[$start] = $category_table[$src];
  2046. $direction_table[$start] = $direction_table[$src];
  2047. $combining_class_table[$start] = $combining_class_table[$src];
  2048. $start++;
  2049. }
  2050. }
  2051. next if $decomp eq ""; # no decomposition, skip it
  2052. if ($decomp =~ /^<([a-zA-Z]+)>\s+([0-9a-fA-F]+)/)
  2053. {
  2054. my @seq = map { hex $_; } (split /\s+/, (split /\s+/, $decomp, 2)[1]);
  2055. $decomp_compat_table[$src] = \@seq;
  2056. }
  2057. if ($decomp =~ /^<([a-zA-Z]+)>\s+([0-9a-fA-F]+)$/)
  2058. {
  2059. # decomposition of the form "<foo> 1234" -> use char if type is known
  2060. if ($1 eq "isolated" || $1 eq "final" || $1 eq "initial" || $1 eq "medial")
  2061. {
  2062. ${joining_forms{$1}}[hex $2] = $src;
  2063. }
  2064. }
  2065. elsif ($decomp =~ /^<compat>\s+0020\s+([0-9a-fA-F]+)/)
  2066. {
  2067. # decomposition "<compat> 0020 1234" -> combining accent
  2068. }
  2069. elsif ($decomp =~ /^([0-9a-fA-F]+)/)
  2070. {
  2071. # store decomposition
  2072. if ($decomp =~ /^([0-9a-fA-F]+)\s+([0-9a-fA-F]+)$/)
  2073. {
  2074. $decomp_table[$src] = $decomp_compat_table[$src] = [ hex $1, hex $2 ];
  2075. }
  2076. elsif ($decomp =~ /^([0-9a-fA-F]+)$/)
  2077. {
  2078. # Single char decomposition
  2079. $decomp_table[$src] = $decomp_compat_table[$src] = [ hex $1 ];
  2080. }
  2081. }
  2082. }
  2083. close $UNICODE_DATA;
  2084. # patch the category of some special characters
  2085. for (my $i = 0; $i < @decomp_table; $i++)
  2086. {
  2087. next unless defined $decomp_table[$i];
  2088. $category_table[$i] |= $category_table[$decomp_table[$i]->[0]];
  2089. }
  2090. foreach my $cat (keys %special_categories)
  2091. {
  2092. my $flag = $ctype{$cat};
  2093. foreach my $i (@{$special_categories{$cat}}) { $category_table[$i] |= $flag; }
  2094. }
  2095. for (my $i = 0; $i < @decomp_compat_table; $i++)
  2096. {
  2097. next unless defined $decomp_compat_table[$i];
  2098. next unless @{$decomp_compat_table[$i]} == 2;
  2099. $category_table[$i] |= $category_table[$decomp_compat_table[$i]->[1]] & $ctype{"diacritic"};
  2100. }
  2101. # load the composition exclusions
  2102. my $EXCL = open_data_file( $UNIDATA, "CompositionExclusions.txt" );
  2103. while (<$EXCL>)
  2104. {
  2105. s/\#.*//; # remove comments
  2106. if (/^([0-9a-fA-F]+)\.\.([0-9a-fA-F]+)\s*$/)
  2107. {
  2108. foreach my $i (hex $1 .. hex $2) { $comp_exclusions[$i] = 1; }
  2109. }
  2110. elsif (/^([0-9a-fA-F]+)\s*$/)
  2111. {
  2112. $comp_exclusions[hex $1] = 1;
  2113. }
  2114. }
  2115. close $EXCL;
  2116. # load the IDNA mappings
  2117. @idna_decomp_table = @decomp_compat_table;
  2118. my $IDNA = open_data_file( $IDNADATA, "IdnaMappingTable.txt" );
  2119. while (<$IDNA>)
  2120. {
  2121. s/\#.*//; # remove comments
  2122. next if /^\s*$/;
  2123. my ($char, $type, $mapping) = split /;/;
  2124. my ($ch1, $ch2);
  2125. if ($char =~ /([0-9a-fA-F]+)\.\.([0-9a-fA-F]+)/)
  2126. {
  2127. $ch1 = hex $1;
  2128. $ch2 = hex $2;
  2129. }
  2130. elsif ($char =~ /([0-9a-fA-F]+)/)
  2131. {
  2132. $ch1 = $ch2 = hex $1;
  2133. }
  2134. if ($type =~ /mapped/ || $type =~ /deviation/)
  2135. {
  2136. $mapping =~ s/^\s*(([0-9a-fA-F]+\s+)+)\s*$/$1/;
  2137. my @seq = map { hex $_; } split /\s+/, $mapping;
  2138. foreach my $i ($ch1 .. $ch2) { $idna_decomp_table[$i] = @seq ? \@seq : [ 0 ]; }
  2139. }
  2140. elsif ($type =~ /valid/)
  2141. {
  2142. }
  2143. elsif ($type =~ /ignored/)
  2144. {
  2145. foreach my $i ($ch1 .. $ch2) { $idna_decomp_table[$i] = [ 0 ]; }
  2146. }
  2147. elsif ($type =~ /disallowed/)
  2148. {
  2149. foreach my $i ($ch1 .. $ch2)
  2150. {
  2151. $idna_decomp_table[$i] = undef;
  2152. $idna_disallowed[$i] = 1;
  2153. }
  2154. }
  2155. }
  2156. close $IDNA;
  2157. }
  2158. ################################################################
  2159. # add a new registry key
  2160. sub add_registry_key($$)
  2161. {
  2162. my ($key, $defval) = @_;
  2163. $registry_keys{$key} = [ $defval ] unless defined $registry_keys{$key};
  2164. }
  2165. ################################################################
  2166. # add a new registry value
  2167. sub add_registry_value($$$)
  2168. {
  2169. my ($key, $name, $value) = @_;
  2170. add_registry_key( $key, undef );
  2171. push @{$registry_keys{$key}}, "'$name' = s '$value'";
  2172. }
  2173. ################################################################
  2174. # define a new lead byte
  2175. sub add_lead_byte($)
  2176. {
  2177. my $ch = shift;
  2178. return if defined $cp2uni[$ch];
  2179. push @lead_bytes, $ch;
  2180. $cp2uni[$ch] = 0;
  2181. }
  2182. ################################################################
  2183. # define a new char mapping
  2184. sub add_mapping($$)
  2185. {
  2186. my ($cp, $uni) = @_;
  2187. $cp2uni[$cp] = $uni unless defined($cp2uni[$cp]);
  2188. $uni2cp[$uni] = $cp unless defined($uni2cp[$uni]);
  2189. if ($cp > 0xff) { add_lead_byte( $cp >> 8 ); }
  2190. }
  2191. ################################################################
  2192. # get a mapping including glyph chars for MB_USEGLYPHCHARS
  2193. sub get_glyphs_mapping(@)
  2194. {
  2195. my @table = @_;
  2196. for (my $i = 0; $i < @glyph2uni; $i++)
  2197. {
  2198. $table[$i] = $glyph2uni[$i] if defined $glyph2uni[$i];
  2199. }
  2200. return @table;
  2201. }
  2202. ################################################################
  2203. # build EUC-JP table from the JIS 0208/0212 files
  2204. sub dump_eucjp_codepage()
  2205. {
  2206. @cp2uni = ();
  2207. @glyph2uni = ();
  2208. @lead_bytes = ();
  2209. @uni2cp = ();
  2210. $default_char = $DEF_CHAR;
  2211. $default_wchar = 0x30fb;
  2212. # ASCII chars
  2213. foreach my $i (0x00 .. 0x7f) { add_mapping( $i, $i ); }
  2214. # lead bytes
  2215. foreach my $i (0x8e, 0xa1 .. 0xfe) { add_lead_byte($i); }
  2216. # JIS X 0201 right plane
  2217. foreach my $i (0xa1 .. 0xdf) { add_mapping( 0x8e00 + $i, 0xfec0 + $i ); }
  2218. # undefined chars
  2219. foreach my $i (0x80 .. 0x8d, 0x8f .. 0x9f) { $cp2uni[$i] = $i; }
  2220. $cp2uni[0xa0] = 0xf8f0;
  2221. $cp2uni[0xff] = 0xf8f3;
  2222. # Fix backslash conversion
  2223. add_mapping( 0xa1c0, 0xff3c );
  2224. # Add private mappings for rows undefined in JIS 0208/0212
  2225. my $private = 0xe000;
  2226. foreach my $hi (0xf5 .. 0xfe)
  2227. {
  2228. foreach my $lo (0xa1 .. 0xfe)
  2229. {
  2230. add_mapping( ($hi << 8) + $lo, $private++ );
  2231. }
  2232. }
  2233. foreach my $hi (0xf5 .. 0xfe)
  2234. {
  2235. foreach my $lo (0x21 .. 0x7e)
  2236. {
  2237. add_mapping( ($hi << 8) + $lo, $private++ );
  2238. }
  2239. }
  2240. my $INPUT = open_data_file( $JISDATA, "JIS0208.TXT" );
  2241. while (<$INPUT>)
  2242. {
  2243. next if /^\#/; # skip comments
  2244. next if /^$/; # skip empty lines
  2245. next if /\x1a/; # skip ^Z
  2246. if (/^0x[0-9a-fA-F]+\s+0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)\s+(\#.*)?/)
  2247. {
  2248. add_mapping( 0x8080 + hex $1, hex $2 );
  2249. next;
  2250. }
  2251. die "Unrecognized line $_\n";
  2252. }
  2253. close $INPUT;
  2254. $INPUT = open_data_file( $JISDATA, "JIS0212.TXT" );
  2255. while (<$INPUT>)
  2256. {
  2257. next if /^\#/; # skip comments
  2258. next if /^$/; # skip empty lines
  2259. next if /\x1a/; # skip ^Z
  2260. if (/^0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)\s+(\#.*)?/)
  2261. {
  2262. add_mapping( 0x8000 + hex $1, hex $2 );
  2263. next;
  2264. }
  2265. die "Unrecognized line $_\n";
  2266. }
  2267. close $INPUT;
  2268. output_codepage_file( 20932 );
  2269. }
  2270. ################################################################
  2271. # build Korean Wansung table from the KSX1001 file
  2272. sub dump_krwansung_codepage(@)
  2273. {
  2274. my @cp949 = @_;
  2275. @cp2uni = ();
  2276. @glyph2uni = ();
  2277. @lead_bytes = ();
  2278. @uni2cp = ();
  2279. $default_char = 0x3f;
  2280. $default_wchar = 0x003f;
  2281. # ASCII and undefined chars
  2282. foreach my $i (0x00 .. 0x9f) { add_mapping( $i, $i ); }
  2283. add_mapping( 0xa0, 0xf8e6 );
  2284. add_mapping( 0xad, 0xf8e7 );
  2285. add_mapping( 0xae, 0xf8e8 );
  2286. add_mapping( 0xaf, 0xf8e9 );
  2287. add_mapping( 0xfe, 0xf8ea );
  2288. add_mapping( 0xff, 0xf8eb );
  2289. my $INPUT = open_data_file( $KSCDATA, "KSX1001.TXT" );
  2290. while (<$INPUT>)
  2291. {
  2292. next if /^\#/; # skip comments
  2293. next if /^$/; # skip empty lines
  2294. next if /\x1a/; # skip ^Z
  2295. if (/^0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)\s+(\#.*)?/)
  2296. {
  2297. add_mapping( 0x8080 + hex $1, hex $2 );
  2298. next;
  2299. }
  2300. die "Unrecognized line $_\n";
  2301. }
  2302. close $INPUT;
  2303. # get some extra mappings from cp 949
  2304. my @defined_lb;
  2305. map { $defined_lb[$_] = 1; } @lead_bytes;
  2306. foreach my $i (0x0000 .. 0xffff)
  2307. {
  2308. next if ($i >= 0x1100 && $i <= 0x11ff); # range not used in 20949
  2309. next unless defined $cp949[$i];
  2310. if ($cp949[$i] >= 0xff)
  2311. {
  2312. # only add chars for lead bytes that exist in 20949
  2313. my $hi = $cp949[$i] >> 8;
  2314. my $lo = $cp949[$i] & 0xff;
  2315. next unless $defined_lb[$hi];
  2316. next unless $lo >= 0xa1 && $lo <= 0xfe;
  2317. }
  2318. add_mapping( $cp949[$i], $i );
  2319. }
  2320. output_codepage_file( 20949 );
  2321. }
  2322. ################################################################
  2323. # build the sort keys table
  2324. sub dump_sortkeys($)
  2325. {
  2326. my $filename = shift;
  2327. my @sortkeys = ();
  2328. my $INPUT = open_data_file( $REPORTS, $SORTKEYS );
  2329. while (<$INPUT>)
  2330. {
  2331. next if /^\#/; # skip comments
  2332. next if /^$/; # skip empty lines
  2333. next if /\x1a/; # skip ^Z
  2334. next if /^\@version/; # skip @version header
  2335. if (/^([0-9a-fA-F]+)\s+;\s+\[([*.])([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})\.([0-9a-fA-F]+)\]/)
  2336. {
  2337. my ($uni,$variable) = (hex $1, $2);
  2338. next if $uni > 65535;
  2339. $sortkeys[$uni] = [ $uni, hex $3, hex $4, hex $5, hex $6 ];
  2340. next;
  2341. }
  2342. if (/^([0-9a-fA-F]+\s+)+;\s+\[[*.]([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})\.([0-9a-fA-F]+)\]/)
  2343. {
  2344. # multiple character sequence, ignored for now
  2345. next;
  2346. }
  2347. die "$SORTKEYS: Unrecognized line $_\n";
  2348. }
  2349. close $INPUT;
  2350. # compress the keys to 32 bit:
  2351. # key 1 to 16 bits, key 2 to 8 bits, key 3 to 4 bits, key 4 to 1 bit
  2352. @sortkeys = sort { ${$a}[1] <=> ${$b}[1] or
  2353. ${$a}[2] <=> ${$b}[2] or
  2354. ${$a}[3] <=> ${$b}[3] or
  2355. ${$a}[4] <=> ${$b}[4] or
  2356. $a cmp $b; } @sortkeys;
  2357. my ($n2, $n3) = (1, 1);
  2358. my @keys = (-1, -1, -1, -1, -1 );
  2359. my @flatkeys = ();
  2360. for (my $i = 0; $i < @sortkeys; $i++)
  2361. {
  2362. next unless defined $sortkeys[$i];
  2363. my @current = @{$sortkeys[$i]};
  2364. if ($current[1] == $keys[1])
  2365. {
  2366. if ($current[2] == $keys[2])
  2367. {
  2368. if ($current[3] == $keys[3])
  2369. {
  2370. # nothing
  2371. }
  2372. else
  2373. {
  2374. $keys[3] = $current[3];
  2375. $n3++;
  2376. die if ($n3 >= 16);
  2377. }
  2378. }
  2379. else
  2380. {
  2381. $keys[2] = $current[2];
  2382. $keys[3] = $current[3];
  2383. $n2++;
  2384. $n3 = 1;
  2385. die if ($n2 >= 256);
  2386. }
  2387. }
  2388. else
  2389. {
  2390. $keys[1] = $current[1];
  2391. $keys[2] = $current[2];
  2392. $keys[3] = $current[3];
  2393. $n2 = 1;
  2394. $n3 = 1;
  2395. }
  2396. if ($current[2]) { $current[2] = $n2; }
  2397. if ($current[3]) { $current[3] = $n3; }
  2398. if ($current[4]) { $current[4] = 1; }
  2399. $flatkeys[$current[0]] = ($current[1] << 16) | ($current[2] << 8) | ($current[3] << 4) | $current[4];
  2400. }
  2401. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  2402. printf "Building $filename\n";
  2403. printf OUTPUT "/* Unicode collation element table */\n";
  2404. printf OUTPUT "/* generated from %s */\n", "$REPORTS/$SORTKEYS";
  2405. printf OUTPUT "/* DO NOT EDIT!! */\n\n";
  2406. print OUTPUT "#include \"windef.h\"\n\n";
  2407. dump_two_level_mapping( "collation_table", 0xffffffff, 32, @flatkeys );
  2408. close OUTPUT;
  2409. save_file($filename);
  2410. }
  2411. ################################################################
  2412. # dump an array of integers
  2413. sub dump_array($$@)
  2414. {
  2415. my ($bit_width, $default, @array) = @_;
  2416. my $format = sprintf "0x%%0%ux", $bit_width / 4;
  2417. my $i;
  2418. my $ret = " ";
  2419. for ($i = 0; $i < $#array; $i++)
  2420. {
  2421. $ret .= sprintf($format, defined $array[$i] ? $array[$i] : $default);
  2422. $ret .= (($i % 8) != 7) ? ", " : ",\n ";
  2423. }
  2424. $ret .= sprintf($format, defined $array[$i] ? $array[$i] : $default);
  2425. return $ret;
  2426. }
  2427. ################################################################
  2428. # dump an SBCS mapping table in binary format
  2429. sub dump_binary_sbcs_table($)
  2430. {
  2431. my $codepage = shift;
  2432. my @header = ( 13, $codepage, 1, $default_char, $default_wchar, $cp2uni[$default_char], $uni2cp[$default_wchar] );
  2433. my $wc_offset = 256 + 3 + (@glyph2uni ? 256 : 0);
  2434. print OUTPUT pack "S<*", @header;
  2435. print OUTPUT pack "C12", (0) x 12;
  2436. print OUTPUT pack "S<*", $wc_offset, map { $_ || 0; } @cp2uni[0 .. 255];
  2437. if (@glyph2uni)
  2438. {
  2439. print OUTPUT pack "S<*", 256, get_glyphs_mapping(@cp2uni[0 .. 255]);
  2440. }
  2441. else
  2442. {
  2443. print OUTPUT pack "S<*", 0;
  2444. }
  2445. print OUTPUT pack "S<*", 0, 0;
  2446. print OUTPUT pack "C*", map { defined $_ ? $_ : $default_char; } @uni2cp[0 .. 65535];
  2447. }
  2448. ################################################################
  2449. # dump a DBCS mapping table in binary format
  2450. sub dump_binary_dbcs_table($)
  2451. {
  2452. my $codepage = shift;
  2453. my @lb_ranges = get_lb_ranges();
  2454. my @header = ( 13, $codepage, 2, $default_char, $default_wchar, $cp2uni[$default_char], $uni2cp[$default_wchar] );
  2455. my @offsets = (0) x 256;
  2456. my $pos = 0;
  2457. foreach my $i (@lead_bytes)
  2458. {
  2459. $offsets[$i] = ($pos += 256);
  2460. $cp2uni[$i] = 0;
  2461. }
  2462. my $wc_offset = 256 + 3 + 256 * (1 + scalar @lead_bytes);
  2463. print OUTPUT pack "S<*", @header;
  2464. print OUTPUT pack "C12", @lb_ranges, 0 x 12;
  2465. print OUTPUT pack "S<*", $wc_offset, map { $_ || 0; } @cp2uni[0 .. 255];
  2466. print OUTPUT pack "S<*", 0, scalar @lb_ranges / 2, @offsets;
  2467. foreach my $i (@lead_bytes)
  2468. {
  2469. my $base = $i << 8;
  2470. print OUTPUT pack "S<*", map { defined $_ ? $_ : $default_wchar; } @cp2uni[$base .. $base + 255];
  2471. }
  2472. print OUTPUT pack "S<", 4;
  2473. print OUTPUT pack "S<*", map { defined $_ ? $_ : $default_char; } @uni2cp[0 .. 65535];
  2474. }
  2475. ################################################################
  2476. # get the list of defined lead byte ranges
  2477. sub get_lb_ranges()
  2478. {
  2479. my @list = ();
  2480. my @ranges = ();
  2481. foreach my $i (@lead_bytes) { $list[$i] = 1; }
  2482. my $on = 0;
  2483. for (my $i = 0; $i < 256; $i++)
  2484. {
  2485. if ($on)
  2486. {
  2487. if (!defined $list[$i]) { push @ranges, $i-1; $on = 0; }
  2488. }
  2489. else
  2490. {
  2491. if ($list[$i]) { push @ranges, $i; $on = 1; }
  2492. }
  2493. }
  2494. if ($on) { push @ranges, 0xff; }
  2495. return @ranges;
  2496. }
  2497. ################################################################
  2498. # dump the Indic Syllabic Category table
  2499. sub dump_indic($)
  2500. {
  2501. my $filename = shift;
  2502. my @indic_table;
  2503. my $INPUT = open_data_file( $UNIDATA, "IndicSyllabicCategory.txt" );
  2504. while (<$INPUT>)
  2505. {
  2506. next if /^\#/; # skip comments
  2507. next if /^\s*$/; # skip empty lines
  2508. next if /\x1a/; # skip ^Z
  2509. if (/^\s*([0-9a-fA-F]+)\s*;\s*([a-zA-Z_]+)\s*#/)
  2510. {
  2511. my $type = $2;
  2512. die "unknown indic $type" unless defined $indic_types{$type};
  2513. if (hex $1 < 65536)
  2514. {
  2515. $indic_table[hex $1] = $indic_types{$type};
  2516. }
  2517. next;
  2518. }
  2519. elsif (/^\s*([0-9a-fA-F]+)\.\.\s*([0-9a-fA-F]+)\s*;\s*([A-Za-z_]+)\s*#/)
  2520. {
  2521. my $type = $3;
  2522. die "unknown indic $type" unless defined $indic_types{$type};
  2523. if (hex $1 < 65536 and hex $2 < 65536)
  2524. {
  2525. foreach my $i (hex $1 .. hex $2)
  2526. {
  2527. $indic_table[$i] = $indic_types{$type};
  2528. }
  2529. }
  2530. next;
  2531. }
  2532. die "malformed line $_";
  2533. }
  2534. close $INPUT;
  2535. $INPUT = open_data_file( $UNIDATA, "IndicPositionalCategory.txt" );
  2536. while (<$INPUT>)
  2537. {
  2538. next if /^\#/; # skip comments
  2539. next if /^\s*$/; # skip empty lines
  2540. next if /\x1a/; # skip ^Z
  2541. if (/^\s*([0-9a-fA-F]+)\s*;\s*([a-zA-Z_]+)\s*#/)
  2542. {
  2543. my $type = $2;
  2544. die "unknown matra $type" unless defined $matra_types{$type};
  2545. $indic_table[hex $1] |= $matra_types{$type} << 8;
  2546. next;
  2547. }
  2548. elsif (/^\s*([0-9a-fA-F]+)\.\.\s*([0-9a-fA-F]+)\s*;\s*([A-Za-z_]+)\s*#/)
  2549. {
  2550. my $type = $3;
  2551. die "unknown matra $type" unless defined $matra_types{$type};
  2552. foreach my $i (hex $1 .. hex $2)
  2553. {
  2554. $indic_table[$i] |= $matra_types{$type} << 8;
  2555. }
  2556. next;
  2557. }
  2558. die "malformed line $_";
  2559. }
  2560. close $INPUT;
  2561. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  2562. print "Building $filename\n";
  2563. print OUTPUT "/* Unicode Indic Syllabic Category */\n";
  2564. print OUTPUT "/* generated from $UNIDATA:IndicSyllabicCategory.txt */\n";
  2565. print OUTPUT "/* and from $UNIDATA:IndicPositionalCategory.txt */\n";
  2566. print OUTPUT "/* DO NOT EDIT!! */\n\n";
  2567. print OUTPUT "#include \"windef.h\"\n\n";
  2568. dump_two_level_mapping( "indic_syllabic_table", $indic_types{'Other'}, 16, @indic_table );
  2569. close OUTPUT;
  2570. save_file($filename);
  2571. }
  2572. ################################################################
  2573. # dump the Line Break Properties table
  2574. sub dump_linebreak($)
  2575. {
  2576. my $filename = shift;
  2577. my @break_table;
  2578. my $INPUT = open_data_file( $UNIDATA, "LineBreak.txt" );
  2579. while (<$INPUT>)
  2580. {
  2581. next if /^\#/; # skip comments
  2582. next if /^\s*$/; # skip empty lines
  2583. next if /\x1a/; # skip ^Z
  2584. if (/^\s*([0-9a-fA-F]+)\s*;\s*([0-9A-Z][0-9A-Z][0-9A-Z])+\s*/)
  2585. {
  2586. my $type = $2;
  2587. die "unknown breaktype $type" unless defined $break_types{$type};
  2588. $break_table[hex $1] = $break_types{$type};
  2589. next;
  2590. }
  2591. elsif (/^\s*([0-9a-fA-F]+)\.\.\s*([0-9a-fA-F]+)\s*;\s*([0-9A-Z][0-9A-Z][0-9A-Z])+\s*/)
  2592. {
  2593. my $type = $3;
  2594. die "unknown breaktype $type" unless defined $break_types{$type};
  2595. foreach my $i (hex $1 .. hex $2)
  2596. {
  2597. $break_table[$i] = $break_types{$type};
  2598. }
  2599. next;
  2600. }
  2601. elsif (/^\s*([0-9a-fA-F]+)\s*;\s*([0-9A-Z][0-9A-Z])+\s*/)
  2602. {
  2603. my $type = $2;
  2604. die "unknown breaktype $type" unless defined $break_types{$type};
  2605. $break_table[hex $1] = $break_types{$type};
  2606. next;
  2607. }
  2608. elsif (/^\s*([0-9a-fA-F]+)\.\.\s*([0-9a-fA-F]+)\s*;\s*([0-9A-Z][0-9A-Z])+\s*/)
  2609. {
  2610. my $type = $3;
  2611. die "unknown breaktype $type" unless defined $break_types{$type};
  2612. foreach my $i (hex $1 .. hex $2)
  2613. {
  2614. $break_table[$i] = $break_types{$type};
  2615. }
  2616. next;
  2617. }
  2618. die "malformed line $_";
  2619. }
  2620. close $INPUT;
  2621. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  2622. print "Building $filename\n";
  2623. print OUTPUT "/* Unicode Line Break Properties */\n";
  2624. print OUTPUT "/* generated from $UNIDATA:LineBreak.txt */\n";
  2625. print OUTPUT "/* DO NOT EDIT!! */\n\n";
  2626. print OUTPUT "#include \"windef.h\"\n\n";
  2627. dump_two_level_mapping( "wine_linebreak_table", $break_types{'XX'}, 16, @break_table );
  2628. close OUTPUT;
  2629. save_file($filename);
  2630. }
  2631. my %scripts =
  2632. (
  2633. "Unknown" => 0,
  2634. "Common" => 1,
  2635. "Inherited" => 2,
  2636. "Arabic" => 3,
  2637. "Armenian" => 4,
  2638. "Avestan" => 5,
  2639. "Balinese" => 6,
  2640. "Bamum" => 7,
  2641. "Batak" => 8,
  2642. "Bengali" => 9,
  2643. "Bopomofo" => 10,
  2644. "Brahmi" => 11,
  2645. "Braille" => 12,
  2646. "Buginese" => 13,
  2647. "Buhid" => 14,
  2648. "Canadian_Aboriginal" => 15,
  2649. "Carian" => 16,
  2650. "Cham" => 17,
  2651. "Cherokee" => 18,
  2652. "Coptic" => 19,
  2653. "Cuneiform" => 20,
  2654. "Cypriot" => 21,
  2655. "Cyrillic" => 22,
  2656. "Deseret" => 23,
  2657. "Devanagari" => 24,
  2658. "Egyptian_Hieroglyphs" => 25,
  2659. "Ethiopic" => 26,
  2660. "Georgian" => 27,
  2661. "Glagolitic" => 28,
  2662. "Gothic" => 29,
  2663. "Greek" => 30,
  2664. "Gujarati" => 31,
  2665. "Gurmukhi" => 32,
  2666. "Han" => 33,
  2667. "Hangul" => 34,
  2668. "Hanunoo" => 35,
  2669. "Hebrew" => 36,
  2670. "Hiragana" => 37,
  2671. "Imperial_Aramaic" => 38,
  2672. "Inscriptional_Pahlavi" => 39,
  2673. "Inscriptional_Parthian" => 40,
  2674. "Javanese" => 41,
  2675. "Kaithi" => 42,
  2676. "Kannada" => 43,
  2677. "Katakana" => 44,
  2678. "Kayah_Li" => 45,
  2679. "Kharoshthi" => 46,
  2680. "Khmer" => 47,
  2681. "Lao" => 48,
  2682. "Latin" => 49,
  2683. "Lepcha" => 50,
  2684. "Limbu" => 51,
  2685. "Linear_B" => 52,
  2686. "Lisu" => 53,
  2687. "Lycian" => 54,
  2688. "Lydian" => 55,
  2689. "Malayalam" => 56,
  2690. "Mandaic" => 57,
  2691. "Meetei_Mayek" => 58,
  2692. "Mongolian" => 59,
  2693. "Myanmar" => 60,
  2694. "New_Tai_Lue" => 61,
  2695. "Nko" => 62,
  2696. "Ogham" => 63,
  2697. "Ol_Chiki" => 64,
  2698. "Old_Italic" => 65,
  2699. "Old_Persian" => 66,
  2700. "Old_South_Arabian" => 67,
  2701. "Old_Turkic" => 68,
  2702. "Oriya" => 69,
  2703. "Osmanya" => 70,
  2704. "Phags_Pa" => 71,
  2705. "Phoenician" => 72,
  2706. "Rejang" => 73,
  2707. "Runic" => 74,
  2708. "Samaritan" => 75,
  2709. "Saurashtra" => 76,
  2710. "Shavian" => 77,
  2711. "Sinhala" => 78,
  2712. "Sundanese" => 79,
  2713. "Syloti_Nagri" => 80,
  2714. "Syriac" => 81,
  2715. "Tagalog" => 82,
  2716. "Tagbanwa" => 83,
  2717. "Tai_Le" => 84,
  2718. "Tai_Tham" => 85,
  2719. "Tai_Viet" => 86,
  2720. "Tamil" => 87,
  2721. "Telugu" => 88,
  2722. "Thaana" => 89,
  2723. "Thai" => 90,
  2724. "Tibetan" => 91,
  2725. "Tifinagh" => 92,
  2726. "Ugaritic" => 93,
  2727. "Vai" => 94,
  2728. "Yi" => 95,
  2729. # Win8/Win8.1
  2730. "Chakma" => 96,
  2731. "Meroitic_Cursive" => 97,
  2732. "Meroitic_Hieroglyphs" => 98,
  2733. "Miao" => 99,
  2734. "Sharada" => 100,
  2735. "Sora_Sompeng" => 101,
  2736. "Takri" => 102,
  2737. # Win10
  2738. "Bassa_Vah" => 103,
  2739. "Caucasian_Albanian" => 104,
  2740. "Duployan" => 105,
  2741. "Elbasan" => 106,
  2742. "Grantha" => 107,
  2743. "Khojki" => 108,
  2744. "Khudawadi" => 109,
  2745. "Linear_A" => 110,
  2746. "Mahajani" => 111,
  2747. "Manichaean" => 112,
  2748. "Mende_Kikakui" => 113,
  2749. "Modi" => 114,
  2750. "Mro" => 115,
  2751. "Nabataean" => 116,
  2752. "Old_North_Arabian" => 117,
  2753. "Old_Permic" => 118,
  2754. "Pahawh_Hmong" => 119,
  2755. "Palmyrene" => 120,
  2756. "Pau_Cin_Hau" => 121,
  2757. "Psalter_Pahlavi" => 122,
  2758. "Siddham" => 123,
  2759. "Tirhuta" => 124,
  2760. "Warang_Citi" => 125,
  2761. # Win10 RS1
  2762. "Adlam" => 126,
  2763. "Ahom" => 127,
  2764. "Anatolian_Hieroglyphs" => 128,
  2765. "Bhaiksuki" => 129,
  2766. "Hatran" => 130,
  2767. "Marchen" => 131,
  2768. "Multani" => 132,
  2769. "Newa" => 133,
  2770. "Old_Hungarian" => 134,
  2771. "Osage" => 135,
  2772. "SignWriting" => 136,
  2773. "Tangut" => 137,
  2774. # Win10 RS4
  2775. "Masaram_Gondi" => 138,
  2776. "Nushu" => 139,
  2777. "Soyombo" => 140,
  2778. "Zanabazar_Square" => 141,
  2779. # Win10 1903
  2780. "Dogra" => 142,
  2781. "Gunjala_Gondi" => 143,
  2782. "Hanifi_Rohingya" => 144,
  2783. "Makasar" => 145,
  2784. "Medefaidrin" => 146,
  2785. "Old_Sogdian" => 147,
  2786. "Sogdian" => 148,
  2787. # Win10 2004
  2788. "Elymaic" => 149,
  2789. "Nyiakeng_Puachue_Hmong" => 150,
  2790. "Nandinagari" => 151,
  2791. "Wancho" => 152,
  2792. # Win11
  2793. "Chorasmian" => 153,
  2794. "Dives_Akuru" => 154,
  2795. "Khitan_Small_Script" => 155,
  2796. "Yezidi" => 156,
  2797. );
  2798. ################################################################
  2799. # dump Script IDs table
  2800. sub dump_scripts($)
  2801. {
  2802. my $filename = shift;
  2803. my $header = $filename;
  2804. my @scripts_table;
  2805. my $script_index;
  2806. my $i;
  2807. my $INPUT = open_data_file( $UNIDATA, "Scripts.txt" );
  2808. # Fill the table
  2809. # Unknown script id is always 0, so undefined scripts are automatically treated as such
  2810. while (<$INPUT>)
  2811. {
  2812. my $type = "";
  2813. next if /^\#/; # skip comments
  2814. next if /^\s*$/; # skip empty lines
  2815. next if /\x1a/; # skip ^Z
  2816. if (/^\s*([0-9a-fA-F]+)\s*;\s*([a-zA-Z_]+)\s*/)
  2817. {
  2818. $type = $2;
  2819. if (defined $scripts{$type})
  2820. {
  2821. $scripts_table[hex $1] = $scripts{$type};
  2822. }
  2823. next;
  2824. }
  2825. elsif (/^\s*([0-9a-fA-F]+)\.\.\s*([0-9a-fA-F]+)\s*;\s*([a-zA-Z_]+)\s*/)
  2826. {
  2827. $type = $3;
  2828. if (defined $scripts{$type})
  2829. {
  2830. foreach my $i (hex $1 .. hex $2)
  2831. {
  2832. $scripts_table[$i] = $scripts{$type};
  2833. }
  2834. }
  2835. next;
  2836. }
  2837. }
  2838. close $INPUT;
  2839. $header = "$filename.h";
  2840. open OUTPUT,">$header.new" or die "Cannot create $header";
  2841. print "Building $header\n";
  2842. print OUTPUT "/* Unicode Script IDs */\n";
  2843. print OUTPUT "/* generated from $UNIDATA:Scripts.txt */\n";
  2844. print OUTPUT "/* DO NOT EDIT!! */\n\n";
  2845. print OUTPUT "enum unicode_script_id {\n";
  2846. foreach my $script (sort { $scripts{$a} <=> $scripts{$b} } keys %scripts)
  2847. {
  2848. print OUTPUT " Script_$script = $scripts{$script},\n";
  2849. }
  2850. print OUTPUT " Script_LastId = ", (scalar keys %scripts) - 1, "\n";
  2851. print OUTPUT "};\n";
  2852. close OUTPUT;
  2853. save_file($header);
  2854. $filename = "$filename.c";
  2855. open OUTPUT,">$filename.new" or die "Cannot create $header";
  2856. print "Building $filename\n";
  2857. print OUTPUT "/* Unicode Script IDs */\n";
  2858. print OUTPUT "/* generated from $UNIDATA:Scripts.txt */\n";
  2859. print OUTPUT "/* DO NOT EDIT!! */\n\n";
  2860. print OUTPUT "#include \"windef.h\"\n\n";
  2861. dump_two_level_mapping( "wine_scripts_table", 0, 16, @scripts_table );
  2862. close OUTPUT;
  2863. save_file($filename);
  2864. }
  2865. ################################################################
  2866. # dump the BiDi mirroring table
  2867. sub dump_mirroring($)
  2868. {
  2869. my $filename = shift;
  2870. my @mirror_table = ();
  2871. my $INPUT = open_data_file( $UNIDATA, "BidiMirroring.txt" );
  2872. while (<$INPUT>)
  2873. {
  2874. next if /^\#/; # skip comments
  2875. next if /^$/; # skip empty lines
  2876. next if /\x1a/; # skip ^Z
  2877. if (/^\s*([0-9a-fA-F]+)\s*;\s*([0-9a-fA-F]+)/)
  2878. {
  2879. $mirror_table[hex $1] = hex $2;
  2880. next;
  2881. }
  2882. die "malformed line $_";
  2883. }
  2884. close $INPUT;
  2885. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  2886. print "Building $filename\n";
  2887. print OUTPUT "/* Unicode BiDi mirroring */\n";
  2888. print OUTPUT "/* generated from $UNIDATA:BidiMirroring.txt */\n";
  2889. print OUTPUT "/* DO NOT EDIT!! */\n\n";
  2890. print OUTPUT "#include \"windef.h\"\n\n";
  2891. dump_two_level_mapping( "wine_mirror_map", 0, 16, @mirror_table );
  2892. close OUTPUT;
  2893. save_file($filename);
  2894. }
  2895. ################################################################
  2896. # dump the Bidi Brackets
  2897. sub dump_bracket($)
  2898. {
  2899. my $filename = shift;
  2900. my @bracket_table;
  2901. my $INPUT = open_data_file( $UNIDATA, "BidiBrackets.txt" );
  2902. while (<$INPUT>)
  2903. {
  2904. next if /^\#/; # skip comments
  2905. next if /^\s*$/; # skip empty lines
  2906. next if /\x1a/; # skip ^Z
  2907. if (/^\s*([0-9a-fA-F]+)\s*;\s*([0-9a-fA-F]+);\s*([con])/)
  2908. {
  2909. my $type = $3;
  2910. die "unknown bracket $type" unless defined $bracket_types{$type};
  2911. die "characters too distant $1 and $2" if abs(hex($2) - hex($1)) >= 128;
  2912. $bracket_table[hex $1] = (hex($2) - hex($1)) % 255;
  2913. $bracket_table[hex $1] += $bracket_types{$type} << 8;
  2914. next;
  2915. }
  2916. die "malformed line $_";
  2917. }
  2918. close $INPUT;
  2919. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  2920. print "Building $filename\n";
  2921. print OUTPUT "/* Unicode Bidirectional Bracket table */\n";
  2922. print OUTPUT "/* generated from $UNIDATA:BidiBrackets.txt */\n";
  2923. print OUTPUT "/* DO NOT EDIT!! */\n\n";
  2924. print OUTPUT "#include \"windef.h\"\n\n";
  2925. dump_two_level_mapping( "bidi_bracket_table", 0, 16, @bracket_table );
  2926. close OUTPUT;
  2927. save_file($filename);
  2928. }
  2929. ################################################################
  2930. # dump the Arabic shaping table
  2931. sub dump_shaping($)
  2932. {
  2933. my $filename = shift;
  2934. my @joining_table = @initial_joining_table;
  2935. my $INPUT = open_data_file( $UNIDATA, "ArabicShaping.txt" );
  2936. while (<$INPUT>)
  2937. {
  2938. next if /^\#/; # skip comments
  2939. next if /^\s*$/; # skip empty lines
  2940. next if /\x1a/; # skip ^Z
  2941. if (/^\s*([0-9a-fA-F]+)\s*;.*;\s*([RLDCUT])\s*;\s*(\w+)/)
  2942. {
  2943. my $type = $2;
  2944. $joining_table[hex $1] = $joining_types{$type};
  2945. next;
  2946. }
  2947. die "malformed line $_";
  2948. }
  2949. close $INPUT;
  2950. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  2951. print "Building $filename\n";
  2952. print OUTPUT "/* Unicode Arabic shaping */\n";
  2953. print OUTPUT "/* generated from $UNIDATA:ArabicShaping.txt */\n";
  2954. print OUTPUT "/* DO NOT EDIT!! */\n\n";
  2955. print OUTPUT "#include \"windef.h\"\n\n";
  2956. dump_two_level_mapping( "wine_shaping_table", 0, 16, @joining_table );
  2957. print OUTPUT "\nconst unsigned short DECLSPEC_HIDDEN wine_shaping_forms[256][4] =\n{\n";
  2958. for (my $i = 0x600; $i <= 0x6ff; $i++)
  2959. {
  2960. printf OUTPUT " { 0x%04x, 0x%04x, 0x%04x, 0x%04x },\n",
  2961. ${joining_forms{"isolated"}}[$i] || $i,
  2962. ${joining_forms{"final"}}[$i] || $i,
  2963. ${joining_forms{"initial"}}[$i] || $i,
  2964. ${joining_forms{"medial"}}[$i] || $i;
  2965. }
  2966. print OUTPUT "};\n";
  2967. close OUTPUT;
  2968. save_file($filename);
  2969. }
  2970. ################################################################
  2971. # dump the Arabic shaping table
  2972. sub dump_arabic_shaping($)
  2973. {
  2974. my $filename = shift;
  2975. my @joining_table = @initial_joining_table;
  2976. my $INPUT = open_data_file( $UNIDATA, "ArabicShaping.txt" );
  2977. while (<$INPUT>)
  2978. {
  2979. next if /^\#/; # skip comments
  2980. next if /^\s*$/; # skip empty lines
  2981. next if /\x1a/; # skip ^Z
  2982. if (/^\s*([0-9a-fA-F]+)\s*;.*;\s*([RLDCUT])\s*;\s*(\w+)/)
  2983. {
  2984. my $type = $2;
  2985. my $group = $3;
  2986. if ($group eq "ALAPH" || $group eq "DALATH RISH")
  2987. {
  2988. $joining_table[hex $1] = $joining_types{$group};
  2989. }
  2990. else
  2991. {
  2992. $joining_table[hex $1] = $joining_types{$type};
  2993. }
  2994. next;
  2995. }
  2996. die "malformed line $_";
  2997. }
  2998. close $INPUT;
  2999. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  3000. print "Building $filename\n";
  3001. print OUTPUT "/* Unicode Arabic shaping */\n";
  3002. print OUTPUT "/* generated from $UNIDATA:ArabicShaping.txt */\n";
  3003. print OUTPUT "/* DO NOT EDIT!! */\n\n";
  3004. print OUTPUT "#include \"windef.h\"\n\n";
  3005. dump_two_level_mapping( "arabic_shaping_table", 0, 16, @joining_table );
  3006. close OUTPUT;
  3007. save_file($filename);
  3008. }
  3009. ################################################################
  3010. # dump the Vertical Orientation table
  3011. sub dump_vertical($$)
  3012. {
  3013. my ($filename, $unix) = @_;
  3014. my @vertical_table;
  3015. my $INPUT = open_data_file( $UNIDATA, "VerticalOrientation.txt" );
  3016. while (<$INPUT>)
  3017. {
  3018. next if /^\#/; # skip comments
  3019. next if /^\s*$/; # skip empty lines
  3020. next if /\x1a/; # skip ^Z
  3021. if (/^\s*([0-9a-fA-F]+)\s*;\s*([a-zA-Z_]+)\s*/)
  3022. {
  3023. my $type = $2;
  3024. die "unknown vertical $type" unless defined $vertical_types{$type};
  3025. if (hex $1 < 65536)
  3026. {
  3027. $vertical_table[hex $1] = $vertical_types{$type};
  3028. }
  3029. next;
  3030. }
  3031. elsif (/^\s*([0-9a-fA-F]+)\.\.\s*([0-9a-fA-F]+)\s*;\s*([A-Za-z_]+)\s*/)
  3032. {
  3033. my $type = $3;
  3034. die "unknown vertical $type" unless defined $vertical_types{$type};
  3035. foreach my $i (hex $1 .. hex $2)
  3036. {
  3037. $vertical_table[$i] = $vertical_types{$type};
  3038. }
  3039. next;
  3040. }
  3041. die "malformed line $_";
  3042. }
  3043. close $INPUT;
  3044. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  3045. print "Building $filename\n";
  3046. print OUTPUT "/* Unicode Vertical Orientation */\n";
  3047. print OUTPUT "/* generated from $UNIDATA:VerticalOrientation.txt */\n";
  3048. print OUTPUT "/* DO NOT EDIT!! */\n\n";
  3049. if ($unix)
  3050. {
  3051. print OUTPUT "#if 0\n";
  3052. print OUTPUT "#pragma makedep unix\n";
  3053. print OUTPUT "#endif\n\n";
  3054. }
  3055. print OUTPUT "#include \"windef.h\"\n\n";
  3056. dump_two_level_mapping( "vertical_orientation_table", $vertical_types{'R'}, 16, @vertical_table );
  3057. close OUTPUT;
  3058. save_file($filename);
  3059. }
  3060. ################################################################
  3061. # dump the digit folding tables
  3062. sub dump_digit_folding($)
  3063. {
  3064. my ($filename) = shift;
  3065. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  3066. print "Building $filename\n";
  3067. print OUTPUT "/* Unicode digit folding mappings */\n";
  3068. print OUTPUT "/* generated from $UNIDATA:UnicodeData.txt */\n";
  3069. print OUTPUT "/* DO NOT EDIT!! */\n\n";
  3070. print OUTPUT "#include \"windef.h\"\n\n";
  3071. dump_two_level_mapping( "wine_digitmap", 0, 16, @digitmap_table );
  3072. close OUTPUT;
  3073. save_file($filename);
  3074. }
  3075. ################################################################
  3076. # compress a mapping table by removing identical rows
  3077. sub compress_array($$@)
  3078. {
  3079. my $rows = shift;
  3080. my $def = shift;
  3081. my @table = @_;
  3082. my $len = @table / $rows;
  3083. my @array;
  3084. my $data = "";
  3085. # try to merge table rows
  3086. for (my $row = 0; $row < $rows; $row++)
  3087. {
  3088. my $rowtxt = pack "U*", map { defined($_) ? $_ : $def; } @table[($row * $len)..(($row + 1) * $len - 1)];
  3089. my $pos = index $data, $rowtxt;
  3090. if ($pos == -1)
  3091. {
  3092. # check if the tail of the data can match the start of the new row
  3093. my $first = substr( $rowtxt, 0, 1 );
  3094. for (my $i = length($data) - 1; $i > 0; $i--)
  3095. {
  3096. $pos = index( substr( $data, -$i ), $first );
  3097. last if $pos == -1;
  3098. $i -= $pos;
  3099. next unless substr( $data, -$i ) eq substr( $rowtxt, 0, $i );
  3100. substr( $data, -$i ) = "";
  3101. last;
  3102. }
  3103. $pos = length $data;
  3104. $data .= $rowtxt;
  3105. }
  3106. $array[$row] = $rows + $pos;
  3107. }
  3108. return @array, unpack "U*", $data;
  3109. }
  3110. ################################################################
  3111. # dump a char -> 16-bit value mapping table using two-level tables
  3112. sub dump_two_level_mapping($$@)
  3113. {
  3114. my $name = shift;
  3115. my $def = shift;
  3116. my $size = shift;
  3117. my $type = $size == 16 ? "unsigned short" : "unsigned int";
  3118. my @row_array = compress_array( 4096, $def, @_[0..65535] );
  3119. my @array = compress_array( 256, 0, @row_array[0..4095] );
  3120. for (my $i = 256; $i < @array; $i++) { $array[$i] += @array - 4096; }
  3121. printf OUTPUT "const %s DECLSPEC_HIDDEN %s[%d] =\n{\n", $type, $name, @array + @row_array - 4096;
  3122. printf OUTPUT " /* level 1 offsets */\n%s,\n", dump_array( $size, 0, @array[0..255] );
  3123. printf OUTPUT " /* level 2 offsets */\n%s,\n", dump_array( $size, 0, @array[256..$#array] );
  3124. printf OUTPUT " /* values */\n%s\n};\n", dump_array( $size, 0, @row_array[4096..$#row_array] );
  3125. }
  3126. ################################################################
  3127. # dump a char -> value mapping table using three-level tables
  3128. sub dump_three_level_mapping($$@)
  3129. {
  3130. my $name = shift;
  3131. my $def = shift;
  3132. my $size = shift;
  3133. my $type = $size == 16 ? "unsigned short" : "unsigned int";
  3134. my $level3 = ($MAX_CHAR + 1) / 16;
  3135. my $level2 = $level3 / 16;
  3136. my $level1 = $level2 / 16;
  3137. my @array3 = compress_array( $level3, $def, @_[0..$MAX_CHAR] );
  3138. my @array2 = compress_array( $level2, 0, @array3[0..$level3-1] );
  3139. my @array1 = compress_array( $level1, 0, @array2[0..$level2-1] );
  3140. for (my $i = $level2; $i < @array2; $i++) { $array2[$i] += @array1 + @array2 - $level2 - $level3; }
  3141. for (my $i = $level1; $i < @array1; $i++) { $array1[$i] += @array1 - $level2; }
  3142. printf OUTPUT "const %s DECLSPEC_HIDDEN %s[%u] =\n{\n", $type, $name, @array1 + (@array2 - $level2) + (@array3 - $level3);
  3143. printf OUTPUT " /* level 1 offsets */\n%s,\n", dump_array( $size, 0, @array1[0..$level1-1] );
  3144. printf OUTPUT " /* level 2 offsets */\n%s,\n", dump_array( $size, 0, @array1[$level1..$#array1] );
  3145. printf OUTPUT " /* level 3 offsets */\n%s,\n", dump_array( $size, 0, @array2[$level2..$#array2] );
  3146. printf OUTPUT " /* values */\n%s\n};\n", dump_array( $size, 0, @array3[$level3..$#array3] );
  3147. }
  3148. ################################################################
  3149. # dump a binary case mapping table in l_intl.nls format
  3150. sub dump_binary_case_table(@)
  3151. {
  3152. my (@table) = @_;
  3153. my $max_char = 0x10000;
  3154. my $level1 = $max_char / 16;
  3155. my $level2 = $level1 / 16;
  3156. my @difftable;
  3157. for (my $i = 0; $i < @table; $i++)
  3158. {
  3159. next unless defined $table[$i];
  3160. $difftable[$i] = ($table[$i] - $i) & 0xffff;
  3161. }
  3162. my @row_array = compress_array( $level1, 0, @difftable[0..$max_char-1] );
  3163. my @array = compress_array( $level2, 0, @row_array[0..$level1-1] );
  3164. my $offset = @array - $level1;
  3165. for (my $i = $level2; $i < @array; $i++) { $array[$i] += $offset; }
  3166. return pack "S<*", 1 + $offset + @row_array, @array, @row_array[$level1..$#row_array];
  3167. }
  3168. ################################################################
  3169. # dump case mappings for l_intl.nls
  3170. sub dump_intl_nls($)
  3171. {
  3172. my @upper_table = @toupper_table;
  3173. my @lower_table = @tolower_table;
  3174. remove_linguistic_mappings( \@upper_table, \@lower_table );
  3175. my $upper = dump_binary_case_table( @upper_table );
  3176. my $lower = dump_binary_case_table( @lower_table );
  3177. my $filename = shift;
  3178. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  3179. printf "Building $filename\n";
  3180. binmode OUTPUT;
  3181. print OUTPUT pack "S<", 1; # version
  3182. print OUTPUT $upper;
  3183. print OUTPUT $lower;
  3184. close OUTPUT;
  3185. save_file($filename);
  3186. }
  3187. ################################################################
  3188. # dump the bidi direction table
  3189. sub dump_bidi_dir_table($)
  3190. {
  3191. my $filename = shift;
  3192. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  3193. printf "Building $filename\n";
  3194. printf OUTPUT "/* Unicode BiDi direction table */\n";
  3195. printf OUTPUT "/* Automatically generated; DO NOT EDIT!! */\n\n";
  3196. printf OUTPUT "#include \"windef.h\"\n\n";
  3197. my @table;
  3198. for (my $i = 0; $i < 65536; $i++)
  3199. {
  3200. $table[$i] = $bidi_types{$direction_table[$i]} if defined $direction_table[$i];
  3201. }
  3202. dump_two_level_mapping( "bidi_direction_table", $bidi_types{"L"}, 16, @table );
  3203. close OUTPUT;
  3204. save_file($filename);
  3205. }
  3206. sub rol($$)
  3207. {
  3208. my ($byte, $count) = @_;
  3209. return (($byte << $count) | ($byte >> (8 - $count))) & 0xff;
  3210. }
  3211. ################################################################
  3212. # compress the character properties table
  3213. sub compress_char_props_table($@)
  3214. {
  3215. my $rows = shift;
  3216. my @table = @_;
  3217. my $len = @table / $rows;
  3218. my $pos = 0;
  3219. my @array = (0) x $rows;
  3220. my %sequences;
  3221. # add some predefined sequences
  3222. foreach my $i (0, 0xfb .. 0xff) { $sequences{pack "L*", (rol($i,5)) x $len} = $i; }
  3223. # try to merge table rows
  3224. for (my $row = 0; $row < $rows; $row++)
  3225. {
  3226. my @table_row = map { defined $_ ? $_ : 0x7f; } @table[($row * $len)..(($row + 1) * $len - 1)];
  3227. my $rowtxt = pack "L*", @table_row;
  3228. if (defined($sequences{$rowtxt}))
  3229. {
  3230. # reuse an existing row
  3231. $array[$row] = $sequences{$rowtxt};
  3232. }
  3233. else
  3234. {
  3235. # create a new row
  3236. $sequences{$rowtxt} = $array[$row] = ++$pos;
  3237. push @array, @table_row;
  3238. }
  3239. }
  3240. return @array;
  3241. }
  3242. ################################################################
  3243. # dump a normalization table in binary format
  3244. sub dump_norm_table($)
  3245. {
  3246. my $filename = shift;
  3247. my %forms = ( "nfc" => 1, "nfd" => 2, "nfkc" => 5, "nfkd" => 6, "idna" => 13 );
  3248. my %decomp = ( "nfc" => \@decomp_table,
  3249. "nfd" => \@decomp_table,
  3250. "nfkc" => \@decomp_compat_table,
  3251. "nfkd" => \@decomp_compat_table ,
  3252. "idna" => \@idna_decomp_table );
  3253. open OUTPUT,">$filename.new" or die "Cannot create $filename";
  3254. print "Building $filename\n";
  3255. my $type = $filename;
  3256. $type =~ s!.*/norm(\w+)\.nls!$1!;
  3257. my $compose = $forms{$type} & 1;
  3258. my $compat = !!($forms{$type} & 4) + ($type eq "idna");
  3259. my @version = split /\./, $UNIVERSION;
  3260. # combining classes
  3261. my @classes;
  3262. my @class_values;
  3263. foreach my $c (grep defined, @combining_class_table)
  3264. {
  3265. $classes[$c] = 1 if $c < 0x100;
  3266. }
  3267. for (my $i = 0; $i < @classes; $i++)
  3268. {
  3269. next unless defined $classes[$i];
  3270. $classes[$i] = @class_values;
  3271. push @class_values, $i;
  3272. }
  3273. push @class_values, 0 if (@class_values % 2);
  3274. die "too many classes" if @class_values >= 0x40;
  3275. # character properties
  3276. my @char_props;
  3277. my @decomposed;
  3278. my @comp_hash_table;
  3279. my $comp_hash_size = $compose ? 254 : 0;
  3280. for (my $i = 0; $i <= $MAX_CHAR; $i++)
  3281. {
  3282. next unless defined $combining_class_table[$i];
  3283. if (defined $decomp{$type}->[$i])
  3284. {
  3285. my @dec = get_decomposition( $i, $decomp{$type} );
  3286. if ($compose && (my @comp = get_composition( $i, $compat )))
  3287. {
  3288. my $hash = ($comp[0] + 95 * $comp[1]) % $comp_hash_size;
  3289. push @{$comp_hash_table[$hash]}, to_utf16( @comp, $i );
  3290. my $val = 0;
  3291. foreach my $d (@dec)
  3292. {
  3293. $val = $combining_class_table[$d];
  3294. last if $val;
  3295. }
  3296. $char_props[$i] = $classes[$val];
  3297. }
  3298. else
  3299. {
  3300. $char_props[$i] = 0xbf;
  3301. }
  3302. @dec = compose_hangul( @dec ) if $compose;
  3303. @dec = to_utf16( @dec );
  3304. push @dec, 0 if @dec >= 7;
  3305. $decomposed[$i] = \@dec;
  3306. }
  3307. else
  3308. {
  3309. if ($combining_class_table[$i] == 0x100)
  3310. {
  3311. $char_props[$i] = 0x7f;
  3312. }
  3313. elsif ($combining_class_table[$i])
  3314. {
  3315. $char_props[$i] = $classes[$combining_class_table[$i]] | 0x80;
  3316. }
  3317. elsif ($type eq "idna" && defined $idna_disallowed[$i])
  3318. {
  3319. $char_props[$i] = 0xff;
  3320. }
  3321. else
  3322. {
  3323. $char_props[$i] = 0;
  3324. }
  3325. }
  3326. }
  3327. if ($compose)
  3328. {
  3329. for (my $i = 0; $i <= $MAX_CHAR; $i++)
  3330. {
  3331. my @comp = get_composition( $i, $compat );
  3332. next unless @comp;
  3333. if ($combining_class_table[$comp[1]])
  3334. {
  3335. $char_props[$comp[0]] |= 0x40 unless $char_props[$comp[0]] & 0x80;
  3336. $char_props[$comp[1]] |= 0x40;
  3337. }
  3338. else
  3339. {
  3340. $char_props[$comp[0]] = ($char_props[$comp[0]] & ~0x40) | 0x80;
  3341. $char_props[$comp[1]] |= 0xc0;
  3342. }
  3343. }
  3344. }
  3345. # surrogates
  3346. foreach my $i (0xd800..0xdbff) { $char_props[$i] = 0xdf; }
  3347. foreach my $i (0xdc00..0xdfff) { $char_props[$i] = 0x9f; }
  3348. # Hangul
  3349. if ($type eq "nfc") { foreach my $i (0x1100..0x117f) { $char_props[$i] = 0xff; } }
  3350. elsif ($compose) { foreach my $i (0x1100..0x11ff) { $char_props[$i] = 0xff; } }
  3351. foreach my $i (0xac00..0xd7ff) { $char_props[$i] = 0xff; }
  3352. # invalid chars
  3353. if ($type eq "idna") { foreach my $i (0x00..0x1f, 0x7f) { $char_props[$i] = 0xff; } }
  3354. foreach my $i (0xfdd0..0xfdef) { $char_props[$i] = 0xff; }
  3355. foreach my $i (0x00..0x10)
  3356. {
  3357. $char_props[($i << 16) | 0xfffe] = 0xff;
  3358. $char_props[($i << 16) | 0xffff] = 0xff;
  3359. }
  3360. # decomposition hash table
  3361. my @decomp_hash_table;
  3362. my @decomp_hash_index;
  3363. my @decomp_hash_data;
  3364. my $decomp_hash_size = 944;
  3365. # build string of character data, reusing substrings when possible
  3366. my $decomp_char_data = "";
  3367. foreach my $i (sort { @{$b} <=> @{$a} } grep defined, @decomposed)
  3368. {
  3369. my $str = pack "U*", @{$i};
  3370. $decomp_char_data .= $str if index( $decomp_char_data, $str) == -1;
  3371. }
  3372. for (my $i = 0; $i < @decomposed; $i++)
  3373. {
  3374. next unless defined $decomposed[$i];
  3375. my $pos = index( $decomp_char_data, pack( "U*", @{$decomposed[$i]} ));
  3376. die "sequence not found" if $pos == -1;
  3377. my $len = @{$decomposed[$i]};
  3378. $len = 7 if $len > 7;
  3379. my $hash = $i % $decomp_hash_size;
  3380. push @{$decomp_hash_table[$hash]}, [ $i, ($len << 13) | $pos ];
  3381. }
  3382. for (my $i = 0; $i < $decomp_hash_size; $i++)
  3383. {
  3384. $decomp_hash_index[$i] = @decomp_hash_data / 2;
  3385. next unless defined $decomp_hash_table[$i];
  3386. if (@{$decomp_hash_table[$i]} == 1)
  3387. {
  3388. my $entry = $decomp_hash_table[$i]->[0];
  3389. if ($char_props[$entry->[0]] == 0xbf)
  3390. {
  3391. $decomp_hash_index[$i] = $entry->[1];
  3392. next;
  3393. }
  3394. }
  3395. foreach my $entry (@{$decomp_hash_table[$i]})
  3396. {
  3397. push @decomp_hash_data, $entry->[0] & 0xffff, $entry->[1];
  3398. }
  3399. }
  3400. push @decomp_hash_data, 0, 0;
  3401. # composition hash table
  3402. my @comp_hash_index;
  3403. my @comp_hash_data;
  3404. if (@comp_hash_table)
  3405. {
  3406. for (my $i = 0; $i < $comp_hash_size; $i++)
  3407. {
  3408. $comp_hash_index[$i] = @comp_hash_data;
  3409. push @comp_hash_data, @{$comp_hash_table[$i]} if defined $comp_hash_table[$i];
  3410. }
  3411. $comp_hash_index[$comp_hash_size] = @comp_hash_data;
  3412. push @comp_hash_data, 0, 0, 0;
  3413. }
  3414. my $level1 = ($MAX_CHAR + 1) / 128;
  3415. my @rows = compress_char_props_table( $level1, @char_props[0..$MAX_CHAR] );
  3416. my @header = ( $version[0], $version[1], $version[2], 0, $forms{$type}, $compat ? 18 : 3,
  3417. 0, $decomp_hash_size, $comp_hash_size, 0 );
  3418. my @tables = (0) x 8;
  3419. $tables[0] = 16 + @header + @tables;
  3420. $tables[1] = $tables[0] + @class_values / 2;
  3421. $tables[2] = $tables[1] + $level1 / 2;
  3422. $tables[3] = $tables[2] + (@rows - $level1) / 2;
  3423. $tables[4] = $tables[3] + @decomp_hash_index;
  3424. $tables[5] = $tables[4] + @decomp_hash_data;
  3425. $tables[6] = $tables[5] + length $decomp_char_data;
  3426. $tables[7] = $tables[6] + @comp_hash_index;
  3427. print OUTPUT pack "S<16", unpack "U*", "norm$type.nlp";
  3428. print OUTPUT pack "S<*", @header;
  3429. print OUTPUT pack "S<*", @tables;
  3430. print OUTPUT pack "C*", @class_values;
  3431. print OUTPUT pack "C*", @rows[0..$level1-1];
  3432. print OUTPUT pack "C*", @rows[$level1..$#rows];
  3433. print OUTPUT pack "S<*", @decomp_hash_index;
  3434. print OUTPUT pack "S<*", @decomp_hash_data;
  3435. print OUTPUT pack "S<*", unpack "U*", $decomp_char_data;
  3436. print OUTPUT pack "S<*", @comp_hash_index;
  3437. print OUTPUT pack "S<*", @comp_hash_data;
  3438. close OUTPUT;
  3439. save_file($filename);
  3440. add_registry_value( "Normalization", sprintf( "%x", $forms{$type} ), "norm$type.nls" );
  3441. }
  3442. ################################################################
  3443. # output a codepage definition file from the global tables
  3444. sub output_codepage_file($)
  3445. {
  3446. my $codepage = shift;
  3447. my $output = sprintf "nls/c_%03d.nls", $codepage;
  3448. open OUTPUT,">$output.new" or die "Cannot create $output";
  3449. printf "Building %s\n", $output;
  3450. if (!@lead_bytes) { dump_binary_sbcs_table( $codepage ); }
  3451. else { dump_binary_dbcs_table( $codepage ); }
  3452. close OUTPUT;
  3453. save_file($output);
  3454. add_registry_value( "Codepage", sprintf( "%d", $codepage ), sprintf( "c_%03d.nls", $codepage ));
  3455. }
  3456. ################################################################
  3457. # output a codepage table from a Microsoft-style mapping file
  3458. sub dump_msdata_codepage($)
  3459. {
  3460. my $filename = shift;
  3461. my $state = "";
  3462. my ($codepage, $width, $count);
  3463. my ($lb_cur, $lb_end);
  3464. @cp2uni = ();
  3465. @glyph2uni = ();
  3466. @lead_bytes = ();
  3467. @uni2cp = ();
  3468. $default_char = $DEF_CHAR;
  3469. $default_wchar = $DEF_CHAR;
  3470. my $INPUT = open_data_file( $MSCODEPAGES, $filename ) or die "Cannot open $filename";
  3471. while (<$INPUT>)
  3472. {
  3473. next if /^;/; # skip comments
  3474. next if /^\s*$/; # skip empty lines
  3475. next if /\x1a/; # skip ^Z
  3476. last if /^ENDCODEPAGE/;
  3477. if (/^CODEPAGE\s+(\d+)/)
  3478. {
  3479. $codepage = $1;
  3480. next;
  3481. }
  3482. if (/^CPINFO\s+(\d+)\s+0x([0-9a-fA-f]+)\s+0x([0-9a-fA-F]+)/)
  3483. {
  3484. $width = $1;
  3485. $default_char = hex $2;
  3486. $default_wchar = hex $3;
  3487. next;
  3488. }
  3489. if (/^(MBTABLE|GLYPHTABLE|WCTABLE|DBCSRANGE|DBCSTABLE)\s+(\d+)/)
  3490. {
  3491. $state = $1;
  3492. $count = $2;
  3493. next;
  3494. }
  3495. if (/^0x([0-9a-fA-F]+)\s+0x([0-9a-fA-F]+)/)
  3496. {
  3497. if ($state eq "MBTABLE")
  3498. {
  3499. my $cp = hex $1;
  3500. my $uni = hex $2;
  3501. $cp2uni[$cp] = $uni unless defined($cp2uni[$cp]);
  3502. next;
  3503. }
  3504. if ($state eq "GLYPHTABLE")
  3505. {
  3506. my $cp = hex $1;
  3507. my $uni = hex $2;
  3508. $glyph2uni[$cp] = $uni unless defined($glyph2uni[$cp]);
  3509. next;
  3510. }
  3511. if ($state eq "WCTABLE")
  3512. {
  3513. my $uni = hex $1;
  3514. my $cp = hex $2;
  3515. $uni2cp[$uni] = $cp unless defined($uni2cp[$uni]);
  3516. next;
  3517. }
  3518. if ($state eq "DBCSRANGE")
  3519. {
  3520. my $start = hex $1;
  3521. my $end = hex $2;
  3522. for (my $i = $start; $i <= $end; $i++) { add_lead_byte( $i ); }
  3523. $lb_cur = $start;
  3524. $lb_end = $end;
  3525. next;
  3526. }
  3527. if ($state eq "DBCSTABLE")
  3528. {
  3529. my $mb = hex $1;
  3530. my $uni = hex $2;
  3531. my $cp = ($lb_cur << 8) | $mb;
  3532. $cp2uni[$cp] = $uni unless defined($cp2uni[$cp]);
  3533. if (!--$count)
  3534. {
  3535. if (++$lb_cur > $lb_end) { $state = "DBCSRANGE"; }
  3536. }
  3537. next;
  3538. }
  3539. }
  3540. die "$filename: Unrecognized line $_\n";
  3541. }
  3542. close $INPUT;
  3543. output_codepage_file( $codepage );
  3544. if ($codepage == 949) { dump_krwansung_codepage( @uni2cp ); }
  3545. }
  3546. ################################################################
  3547. # align a string length
  3548. sub align_string($$)
  3549. {
  3550. my ($align, $str) = @_;
  3551. $str .= pack "C*", (0) x ($align - length($str) % $align) if length($str) % $align;
  3552. return $str;
  3553. }
  3554. ################################################################
  3555. # pad a string with zeros
  3556. sub pad_string($$)
  3557. {
  3558. my ($pad, $str) = @_;
  3559. $str .= pack "C*", (0) x ($pad - length($str)) if length($str) < $pad;
  3560. return $str;
  3561. }
  3562. ################################################################
  3563. # pack a GUID string
  3564. sub pack_guid($)
  3565. {
  3566. $_ = shift;
  3567. /([0-9A-Fa-f]{8})-([0-9A-Fa-f]{4})-([0-9A-Fa-f]{4})-([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})-([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})/;
  3568. return pack "L<S<2C8", hex $1, hex $2, hex $3, hex $4, hex $5, hex $6, hex $7, hex $8, hex $9, hex $10, hex $11;
  3569. }
  3570. ################################################################
  3571. # comparison function for compression sort
  3572. sub cmp_compression
  3573. {
  3574. return scalar @{$a} <=> scalar @{$b} ||
  3575. $a->[4] <=> $b->[4] ||
  3576. $a->[5] <=> $b->[5] ||
  3577. $a->[6] <=> $b->[6] ||
  3578. $a->[7] <=> $b->[7] ||
  3579. $a->[8] <=> $b->[8] ||
  3580. $a->[9] <=> $b->[9] ||
  3581. $a->[10] <=> $b->[10] ||
  3582. $a->[11] <=> $b->[11] ||
  3583. $a->[12] <=> $b->[12];
  3584. }
  3585. ################################################################
  3586. # build a binary sort keys table
  3587. sub dump_sortkey_table($$)
  3588. {
  3589. my ($filename, $download) = @_;
  3590. my @keys;
  3591. my ($part, $section, $subsection, $guid, $version, $ling_flag);
  3592. my @multiple_weights;
  3593. my @expansions;
  3594. my @compressions;
  3595. my %exceptions;
  3596. my %guids;
  3597. my %compr_flags;
  3598. my %locales;
  3599. my $default_guid = "00000001-57ee-1e5c-00b4-d0000bb1e11e";
  3600. my $jamostr = "";
  3601. my $re_hex = '0x[0-9A-Fa-f]+';
  3602. my $re_key = '(\d+\s+\d+\s+\d+\s+\d+)';
  3603. $guids{$default_guid} = { };
  3604. my %flags = ( "HAS_3_BYTE_WEIGHTS" => 0x01, "REVERSEDIACRITICS" => 0x10, "DOUBLECOMPRESSION" => 0x20, "INVERSECASING" => 0x40 );
  3605. my $KEYS = open_data_file( $MSDATA, $download );
  3606. printf "Building $filename\n";
  3607. while (<$KEYS>)
  3608. {
  3609. s/\s*;.*$//;
  3610. next if /^\s*$/; # skip empty lines
  3611. if (/^\s*(SORTKEY|SORTTABLES)/)
  3612. {
  3613. $part = $1;
  3614. next;
  3615. }
  3616. if (/^\s*(ENDSORTKEY|ENDSORTTABLES)/)
  3617. {
  3618. $part = $section = "";
  3619. next;
  3620. }
  3621. if (/^\s*(DEFAULT|RELEASE|REVERSEDIACRITICS|DOUBLECOMPRESSION|INVERSECASING|MULTIPLEWEIGHTS|EXPANSION|COMPATIBILITY|COMPRESSION|EXCEPTION|JAMOSORT)\s+/)
  3622. {
  3623. $section = $1;
  3624. $guid = undef;
  3625. next;
  3626. }
  3627. next unless $part;
  3628. if ("$part.$section" eq "SORTKEY.DEFAULT")
  3629. {
  3630. if (/^\s*($re_hex)\s+$re_key/)
  3631. {
  3632. $keys[hex $1] = [ split(/\s+/,$2) ];
  3633. next;
  3634. }
  3635. }
  3636. elsif ("$part.$section" eq "SORTTABLES.RELEASE")
  3637. {
  3638. if (/^\s*NLSVERSION\s+0x([0-9A-Fa-f]+)/)
  3639. {
  3640. $version = hex $1;
  3641. next;
  3642. }
  3643. if (/^\s*DEFINEDVERSION\s+0x([0-9A-Fa-f]+)/)
  3644. {
  3645. # ignore for now
  3646. next;
  3647. }
  3648. }
  3649. elsif ("$part.$section" eq "SORTTABLES.REVERSEDIACRITICS" ||
  3650. "$part.$section" eq "SORTTABLES.DOUBLECOMPRESSION" ||
  3651. "$part.$section" eq "SORTTABLES.INVERSECASING")
  3652. {
  3653. if (/^\s*SORTGUID\s+([-0-9A-Fa-f]+)/)
  3654. {
  3655. $guid = lc $1;
  3656. $guids{$guid} = { } unless defined $guids{$guid};
  3657. $guids{$guid}->{flags} |= $flags{$section};
  3658. next;
  3659. }
  3660. if (/^\s*LOCALENAME\s+([A-Za-z0-9-_]+)/)
  3661. {
  3662. $locales{$1} = $guid;
  3663. next;
  3664. }
  3665. }
  3666. elsif ("$part.$section" eq "SORTTABLES.MULTIPLEWEIGHTS")
  3667. {
  3668. if (/^\s*(\d+)\s+(\d+)/)
  3669. {
  3670. push @multiple_weights, $1, $2;
  3671. next;
  3672. }
  3673. }
  3674. elsif ("$part.$section" eq "SORTTABLES.EXPANSION")
  3675. {
  3676. if (/^\s*0x([0-9A-Fa-f]+)\s+0x([0-9A-Fa-f]+)\s+0x([0-9A-Fa-f]+)/)
  3677. {
  3678. my $pos = scalar @expansions / 2;
  3679. $keys[hex $1] = [ 2, 0, $pos & 0xff, $pos >> 8 ] unless defined $keys[hex $1];
  3680. push @expansions, hex $2, hex $3;
  3681. next;
  3682. }
  3683. }
  3684. elsif ("$part.$section" eq "SORTTABLES.COMPATIBILITY")
  3685. {
  3686. if (/^\s*0x([0-9A-Fa-f]+)\s+0x([0-9A-Fa-f]+)/)
  3687. {
  3688. $keys[hex $1] = $keys[hex $2];
  3689. next;
  3690. }
  3691. }
  3692. elsif ("$part.$section" eq "SORTTABLES.COMPRESSION")
  3693. {
  3694. if (/^\s*SORTGUID\s+([-0-9A-Fa-f]+)\s+\d*\s*([A-Z0-9_]+)?/)
  3695. {
  3696. if ($subsection || !$guid) # start a new one
  3697. {
  3698. $guid = lc $1;
  3699. $subsection = "";
  3700. $guids{$guid} = { } unless defined $guids{$guid};
  3701. $guids{$guid}->{flags} |= $flags{$2} if $2;
  3702. $guids{$guid}->{compr} = @compressions;
  3703. $exceptions{"$guid-"} = [ ] unless defined $exceptions{"$guid-"};
  3704. $compr_flags{$guid} = [ ] unless defined $compr_flags{$guid};
  3705. push @compressions, [ ];
  3706. }
  3707. else # merge with current one
  3708. {
  3709. $guids{lc $1} = { } unless defined $guids{lc $1};
  3710. $guids{lc $1}->{flags} |= $flags{$2} if $2;
  3711. $guids{lc $1}->{compr} = $guids{$guid}->{compr};
  3712. $compr_flags{lc $1} = $compr_flags{$guid};
  3713. }
  3714. next;
  3715. }
  3716. if (/^\s*LOCALENAME\s+([A-Za-z0-9-_]+)/)
  3717. {
  3718. $locales{$1} = $guid;
  3719. next;
  3720. }
  3721. if (/^\s*(TWO|THREE|FOUR|FIVE|SIX|SEVEN|EIGHT)/)
  3722. {
  3723. $subsection = $1;
  3724. next;
  3725. }
  3726. if ($subsection && /^\s*(($re_hex\s+){2,8})$re_key/)
  3727. {
  3728. my @comp = map { hex $_; } split(/\s+/,$1);
  3729. push @{$compressions[$#compressions]}, [ split(/\s+/,$3), @comp ];
  3730. # add compression flags
  3731. $compr_flags{$guid}->[$comp[0]] |= @comp >= 6 ? 0xc0 : @comp >= 4 ? 0x80 : 0x40;
  3732. next;
  3733. }
  3734. }
  3735. elsif ("$part.$section" eq "SORTTABLES.EXCEPTION")
  3736. {
  3737. if (/^\s*SORTGUID\s+([-0-9A-Fa-f]+)\s+\d*\s*(LINGUISTIC_CASING)?/)
  3738. {
  3739. $guid = lc $1;
  3740. $guids{$guid} = { } unless defined $guids{lc $1};
  3741. $ling_flag = ($2 ? "+" : "-");
  3742. $exceptions{"$guid$ling_flag"} = [ ] unless defined $exceptions{"$guid$ling_flag"};
  3743. next;
  3744. }
  3745. if (/^\s*LOCALENAME\s+([A-Za-z0-9-_]+)/)
  3746. {
  3747. $locales{$1} = $guid;
  3748. next;
  3749. }
  3750. if (/^\s*($re_hex)\s+$re_key/)
  3751. {
  3752. $exceptions{"$guid$ling_flag"}->[hex $1] = [ split(/\s+/,$2) ];
  3753. next;
  3754. }
  3755. }
  3756. elsif ("$part.$section" eq "SORTTABLES.JAMOSORT")
  3757. {
  3758. if (/^\s*$re_hex\s+(($re_hex\s*){5})/)
  3759. {
  3760. $jamostr .= pack "C8", map { hex $_; } split /\s+/, $1;
  3761. next;
  3762. }
  3763. }
  3764. die "$download: $part.$section: unrecognized line $_\n";
  3765. }
  3766. close $KEYS;
  3767. # Sortkey table
  3768. my $table;
  3769. for (my $i = 0; $i < 0x10000; $i++)
  3770. {
  3771. my @k = defined $keys[$i] ? @{$keys[$i]} : (0) x 4;
  3772. $table .= pack "C4", $k[1], $k[0], $k[2], $k[3];
  3773. }
  3774. foreach my $id (sort keys %exceptions)
  3775. {
  3776. my $pos = length($table) / 4;
  3777. my @exc = @{$exceptions{$id}};
  3778. my @filled;
  3779. my $key = (substr( $id, -1 ) eq "+" ? "ling_except" : "except");
  3780. my $guid = substr( $id, 0, -1 );
  3781. $guids{$guid}->{$key} = $pos;
  3782. $pos += 0x100;
  3783. my @flags = @{$compr_flags{$guid}} if defined $compr_flags{$guid};
  3784. for (my $j = 0; $j < 0x10000; $j++)
  3785. {
  3786. next unless defined $exc[$j] || defined $flags[$j];
  3787. $filled[$j >> 8] = 1;
  3788. $j |= 0xff;
  3789. }
  3790. for (my $j = 0; $j < 0x100; $j++)
  3791. {
  3792. $table .= pack "L<", $filled[$j] ? $pos : $j * 0x100;
  3793. $pos += 0x100 if $filled[$j];
  3794. }
  3795. for (my $j = 0; $j < 0x10000; $j++)
  3796. {
  3797. next unless $filled[$j >> 8];
  3798. my @k = defined $exc[$j] ? @{$exc[$j]} : defined $keys[$j] ? @{$keys[$j]} : (0) x 4;
  3799. $k[3] |= $flags[$j] || 0;
  3800. $table .= pack "C4", $k[1], $k[0], $k[2], $k[3];
  3801. }
  3802. }
  3803. # Case mapping tables
  3804. # standard table
  3805. my @casemaps;
  3806. my @upper = @toupper_table;
  3807. my @lower = @tolower_table;
  3808. remove_linguistic_mappings( \@upper, \@lower );
  3809. $casemaps[0] = pack( "S<*", 1) . dump_binary_case_table( @upper ) . dump_binary_case_table( @lower );
  3810. # linguistic table
  3811. $casemaps[1] = pack( "S<*", 1) . dump_binary_case_table( @toupper_table ) . dump_binary_case_table( @tolower_table );
  3812. # Turkish table
  3813. @upper = @toupper_table;
  3814. @lower = @tolower_table;
  3815. $upper[ord 'i'] = 0x130; # LATIN CAPITAL LETTER I WITH DOT ABOVE
  3816. $lower[ord 'I'] = 0x131; # LATIN SMALL LETTER DOTLESS I
  3817. $casemaps[2] = pack( "S<*", 1) . dump_binary_case_table( @upper ) . dump_binary_case_table( @lower );
  3818. my $casemaps = align_string( 8, $casemaps[0] . $casemaps[1] . $casemaps[2] );
  3819. # Char type table
  3820. my @table;
  3821. my $types = "";
  3822. my %typestr;
  3823. for (my $i = 0; $i < 0x10000; $i++)
  3824. {
  3825. my $str = pack "S<3",
  3826. ($category_table[$i] || 0) & 0xffff,
  3827. defined($direction_table[$i]) ? $c2_types{$direction_table[$i]} : 0,
  3828. ($category_table[$i] || 0) >> 16;
  3829. if (!defined($typestr{$str}))
  3830. {
  3831. $typestr{$str} = length($types) / 6;
  3832. $types .= $str;
  3833. }
  3834. $table[$i] = $typestr{$str};
  3835. }
  3836. my @rows = compress_array( 4096, 0, @table[0..65535] );
  3837. my @array = compress_array( 256, 0, @rows[0..4095] );
  3838. for (my $i = 0; $i < 256; $i++) { $array[$i] *= 2; } # we need byte offsets
  3839. for (my $i = 256; $i < @array; $i++) { $array[$i] += 2 * @array - 4096; }
  3840. my $arraystr = pack("S<*", @array) . pack("C*", @rows[4096..$#rows]);
  3841. my $chartypes = pack "S<2", 4 + length($types) + length($arraystr), 2 + length($types);
  3842. $chartypes = align_string( 8, $chartypes . $types . $arraystr );
  3843. # Sort tables
  3844. # guids
  3845. my $sorttables = pack "L<2", $version, scalar %guids;
  3846. foreach my $id (sort keys %guids)
  3847. {
  3848. my %guid = %{$guids{$id}};
  3849. my $flags = $guid{flags} || 0;
  3850. my $map = length($casemaps[0]) + (defined $guid{ling_except} ? length($casemaps[1]) : 0);
  3851. $sorttables .= pack_guid($id) . pack "L<5",
  3852. $flags,
  3853. defined($guid{compr}) ? $guid{compr} : 0xffffffff,
  3854. $guid{except} || 0,
  3855. $guid{ling_except} || 0,
  3856. $map / 2;
  3857. }
  3858. # expansions
  3859. $sorttables .= pack "L<S<*", scalar @expansions / 2, @expansions;
  3860. # compressions
  3861. $sorttables .= pack "L<", scalar @compressions;
  3862. my $rowstr = "";
  3863. foreach my $c (@compressions)
  3864. {
  3865. my $pos = length($rowstr) / 2;
  3866. my $min = 0xffff;
  3867. my $max = 0;
  3868. my @lengths = (0) x 8;
  3869. foreach my $r (sort cmp_compression @{$c})
  3870. {
  3871. my @row = @{$r};
  3872. $lengths[scalar @row - 6]++;
  3873. foreach my $val (@row[4..$#row])
  3874. {
  3875. $min = $val if $min > $val;
  3876. $max = $val if $max < $val;
  3877. }
  3878. $rowstr .= align_string( 4, pack "S<*", @row[4..$#row] );
  3879. $rowstr .= pack "C4", $row[1], $row[0], $row[2], $row[3];
  3880. }
  3881. $sorttables .= pack "L<S<10", $pos, $min, $max, @lengths;
  3882. }
  3883. $sorttables .= $rowstr;
  3884. # multiple weights
  3885. $sorttables .= align_string( 4, pack "L<C*", scalar @multiple_weights / 2, @multiple_weights );
  3886. # jamo sort
  3887. $sorttables .= pack("L<", length($jamostr) / 8) . $jamostr;
  3888. # Locales
  3889. add_registry_key( "Sorting\\Ids", "{$default_guid}" );
  3890. foreach my $loc (sort keys %locales)
  3891. {
  3892. # skip specific locales that match more general ones
  3893. my @parts = split /[-_]/, $loc;
  3894. next if @parts > 1 && defined($locales{$parts[0]}) && $locales{$parts[0]} eq $locales{$loc};
  3895. next if @parts > 2 && defined($locales{"$parts[0]-$parts[1]"}) && $locales{"$parts[0]-$parts[1]"} eq $locales{$loc};
  3896. add_registry_value( "Sorting\\Ids", $loc, "\{$locales{$loc}\}" );
  3897. }
  3898. # File header
  3899. my @header;
  3900. $header[0] = 16;
  3901. $header[1] = $header[0] + length $table;
  3902. $header[2] = $header[1] + length $casemaps;
  3903. $header[3] = $header[2] + length $chartypes;
  3904. open OUTPUT, ">$filename.new" or die "Cannot create $filename";
  3905. print OUTPUT pack "L<*", @header;
  3906. print OUTPUT $table, $casemaps, $chartypes, $sorttables;
  3907. close OUTPUT;
  3908. save_file($filename);
  3909. return $chartypes;
  3910. }
  3911. my %lcnames;
  3912. sub locale_parent($)
  3913. {
  3914. my $loc = shift;
  3915. return undef unless $loc;
  3916. return $lcnames{$loc}->{sparent} if defined $lcnames{$loc} && defined $lcnames{$loc}->{sparent};
  3917. return $lcnames{$loc}->{parent} if defined $lcnames{$loc} && defined $lcnames{$loc}->{parent};
  3918. if ($loc =~ /(.*)-[0-9A-Za-z]+/) { return $1; }
  3919. return "";
  3920. }
  3921. sub compare_locales
  3922. {
  3923. (my $n1 = $a) =~ tr/A-Z_/a-z-/;
  3924. (my $n2 = $b) =~ tr/A-Z_/a-z-/;
  3925. return $n1 cmp $n2;
  3926. }
  3927. # query an xml key
  3928. sub xml_query($$)
  3929. {
  3930. my ($xml, $query) = @_;
  3931. my $ret = $xml->find( $query );
  3932. return undef unless $ret;
  3933. printf STDERR "multiple entries for %s\n", $query if (@{$ret} > 1);
  3934. return @{$ret}[0]->textContent;
  3935. }
  3936. # query an xml key for a locale, with fallback to the parents
  3937. sub loc_query($$)
  3938. {
  3939. my ($loc, $query) = @_;
  3940. $loc = $lcnames{"en-US"} unless $loc->{name}; # fallback to "en-US" for root locale
  3941. for (my $cur = $loc->{name}; defined $cur; $cur = locale_parent( $cur ))
  3942. {
  3943. next unless defined $lcnames{$cur};
  3944. my $xml = $lcnames{$cur}->{xml};
  3945. my $ret = $xml->find( $query );
  3946. next unless $ret;
  3947. printf STDERR "%s: multiple entries for %s\n", $cur, $query if (@{$ret} > 1);
  3948. next if @{$ret}[0]->textContent eq "\x{2191}\x{2191}\x{2191}"; # "↑↑↑"
  3949. return @{$ret}[0]->textContent;
  3950. }
  3951. return undef;
  3952. }
  3953. # retrieve a locale field entry by going up the parents tree
  3954. sub locale_entry($$$)
  3955. {
  3956. my ($loc, $field, $def) = @_;
  3957. return $loc->{$field} if defined $loc->{$field};
  3958. unless ($loc->{name}) # fallback to "en-US" for root locale
  3959. {
  3960. $loc = $lcnames{"en-US"};
  3961. return $loc->{$field} if defined $loc->{$field};
  3962. }
  3963. while (defined $loc->{alias}) # resolve aliases
  3964. {
  3965. $loc = $lcnames{$loc->{alias}};
  3966. return $loc->{$field} if defined $loc->{$field};
  3967. }
  3968. my $cur = $loc->{name};
  3969. while ($cur)
  3970. {
  3971. if (defined $lcnames{$cur} && defined $lcnames{$cur}->{sparent})
  3972. {
  3973. $cur = $lcnames{$cur}->{sparent};
  3974. }
  3975. elsif ($cur =~ /(.*)-[0-9A-Za-z]+/)
  3976. {
  3977. $cur = $1;
  3978. }
  3979. else
  3980. {
  3981. return $def;
  3982. }
  3983. return $lcnames{$cur}->{$field} if defined $lcnames{$cur} && defined $lcnames{$cur}->{$field};
  3984. }
  3985. return $def;
  3986. }
  3987. my $string_data;
  3988. sub add_str_data($)
  3989. {
  3990. my $txt = shift;
  3991. my $ret = index( $string_data, $txt );
  3992. if ($ret == -1)
  3993. {
  3994. $ret = length($string_data);
  3995. $string_data .= $txt
  3996. }
  3997. return $ret / 2;
  3998. }
  3999. sub add_string($)
  4000. {
  4001. my $str = shift;
  4002. return 0 unless defined($str) && $str ne "";
  4003. my $utf = encode( "UTF16LE", $str );
  4004. return add_str_data( (pack "S<", length($utf) / 2) . $utf . (pack "S", 0) );
  4005. }
  4006. sub add_fontsig(@)
  4007. {
  4008. return add_str_data( pack "S<L<*", scalar(@_) * 2, @_ );
  4009. }
  4010. sub add_strarray(@)
  4011. {
  4012. return 0 unless @_;
  4013. return add_str_data( pack "S<L<*", scalar @_, map { add_string($_) } @_);
  4014. }
  4015. sub format_to_grouping($)
  4016. {
  4017. my $format = shift;
  4018. if ($format =~ /#,(#+),(#+0)/) { return chr(length($2)) . chr(length($1)); }
  4019. if ($format =~ /#,(#+0)/) { return chr(length($1)); }
  4020. # printf STDERR "unknown format %s\n", $format;
  4021. return chr(3);
  4022. }
  4023. sub parse_currency_format($$)
  4024. {
  4025. my $name = shift;
  4026. my ($posfmt, $negfmt) = split /;/, shift;
  4027. my @pospatterns = ( "\xa4[^\xa0]*#", # $1.1
  4028. "00[^\xa0]*\xa4", # 1.1$
  4029. "\xa4.*\xa0.*#", # $ 1.1
  4030. "00.*\xa0.*\xa4" ); # 1.1 $
  4031. my @negpatterns = ( "\\(\xa4[^\xa0]*#", # ($1.1)
  4032. "-\xa4[^\xa0]*#", # -$1.1
  4033. "\xa4[^\xa0]*-#", # $-1.1
  4034. "\xa4[^\xa0]*#.*00-", # $1.1-
  4035. "00[^\xa0]*\xa4\\)", # (1.1$)
  4036. "-#.*00[^\xa0]*\xa4", # -1.1$
  4037. "00-[^\xa0]*\xa4", # 1.1-$
  4038. "00[^\xa0]*\xa4-", # 1.1$-
  4039. "-#.*00.*\xa0.*\xa4", # -1.1 $
  4040. "-\xa4.*\xa0.*#", # -$ 1.1
  4041. "00.*\xa0.*\xa4-", # 1.1 $-
  4042. "\xa4.*\xa0.*#.*00-", # $ 1.1-
  4043. "\xa4.*\xa0.*-#", # $ -1.1
  4044. "00-.*\xa0.*\xa4", # 1.1- $
  4045. "\\(\xa4.*\xa0.*#", # ($ 1.1)
  4046. "00.*\xa0.*\xa4\\)"); # (1.1 $)
  4047. my ($pos, $neg);
  4048. for ($pos = 0; $pos < @pospatterns; $pos++)
  4049. {
  4050. last if ($posfmt =~ /$pospatterns[$pos]/);
  4051. }
  4052. #printf STDERR "$name: unknown format '%s'\n", $posfmt if ($pos == @pospatterns);
  4053. $pos = 0 if ($pos == @pospatterns);
  4054. if (defined $negfmt)
  4055. {
  4056. for ($neg = 0; $neg < @negpatterns; $neg++)
  4057. {
  4058. last if ($negfmt =~ /$negpatterns[$neg]/);
  4059. }
  4060. #printf STDERR "$name: unknown format '%s'\n", $negfmt if ($neg == @negpatterns);
  4061. $neg = 0 if ($neg == @negpatterns);
  4062. }
  4063. elsif ($pos == 0) { $neg = 1; }
  4064. elsif ($pos == 1) { $neg = 5; }
  4065. elsif ($pos == 2) { $neg = 9; }
  4066. elsif ($pos == 3) { $neg = 8; }
  4067. return ($pos, $neg);
  4068. }
  4069. sub parse_percent_format($)
  4070. {
  4071. my $fmt = shift;
  4072. my @patterns = ( "0.+%", # 1 %
  4073. "0%", # 1%
  4074. "%#", # %1
  4075. "%.+#" ); # % 1
  4076. my $pos;
  4077. for ($pos = 0; $pos < @patterns; $pos++)
  4078. {
  4079. last if ($fmt =~ /$patterns[$pos]/);
  4080. }
  4081. printf STDERR "unknown format '%s'\n", $fmt if ($pos == @patterns);
  4082. return ($pos, ($pos == 3) ? 7 : $pos);
  4083. }
  4084. sub convert_date_format($)
  4085. {
  4086. my $fmt = shift;
  4087. $fmt =~ s/G+/gg/;
  4088. $fmt =~ s/LLLL/MMMM/;
  4089. $fmt =~ s/LLL/MMM/;
  4090. $fmt =~ s/E+/dddd/;
  4091. $fmt =~ s/ccc+/dddd/;
  4092. $fmt =~ s/([^gy])y([^y])/$1yyyy$2/;
  4093. $fmt =~ s/^y([^y])/yyyy$1/;
  4094. $fmt =~ s/([^gy])y$/$1yyyy/;
  4095. return $fmt;
  4096. }
  4097. sub convert_time_format($)
  4098. {
  4099. my $fmt = shift;
  4100. $fmt =~ s/a+/tt/;
  4101. $fmt =~ s/B+/tt/;
  4102. return $fmt;
  4103. }
  4104. sub load_iso639()
  4105. {
  4106. my %iso639;
  4107. my $DATA = open_data_file( $ISO639, "iso-639-3_Code_Tables_$ISO639VERSION/iso-639-3.tab" );
  4108. while (<$DATA>)
  4109. {
  4110. if (/^\s*[a-z]{3}\s+[a-z]{3}\s+([a-z]{3})\s+([a-z]{2})\s/) { $iso639{$2} = $1; }
  4111. }
  4112. close $DATA;
  4113. return %iso639;
  4114. }
  4115. ################################################################
  4116. # build the locale table for locale.nls
  4117. sub build_locale_data()
  4118. {
  4119. my $base = "cldr-release-$CLDRVERSION";
  4120. my $suppl = load_xml_data_file( $CLDRDATA, "$base/common/supplemental/supplementalData.xml" );
  4121. my $subtags = load_xml_data_file( $CLDRDATA, "$base/common/supplemental/likelySubtags.xml" );
  4122. my $numbers = load_xml_data_file( $CLDRDATA, "$base/common/supplemental/numberingSystems.xml" );
  4123. # obsolete phone data from CLDR version 33
  4124. my $phone = load_xml_data_file( $CLDR33DATA, "common/supplemental/telephoneCodeData.xml" );
  4125. my %iso639 = load_iso639();
  4126. $string_data = pack "S2", 0, 0; # offset 0 == empty string
  4127. %lcnames = map { $_->{name} => $_ } @locales;
  4128. my %lcids;
  4129. foreach my $loc (@locales) { $lcids{$loc->{lcid}} = $loc if defined $loc->{lcid}; }
  4130. my %days = ( "sun" => 0, "mon" => 1, "tue" => 2, "wed" => 3, "thu" => 4, "fri" => 5, "sat" => 6 );
  4131. # assign locale parents
  4132. foreach my $loc (@locales)
  4133. {
  4134. next if $loc->{name} eq "";
  4135. next if defined $loc->{parent};
  4136. (my $unix_name = $loc->{name}) =~ s/-/_/g;
  4137. my $parent = xml_query( $suppl, "/supplementalData/parentLocales/parentLocale[contains(concat(' ',\@locales,' '),' $unix_name ')]/\@parent" );
  4138. if ($parent)
  4139. {
  4140. $parent =~ s/_/-/g;
  4141. $parent = "" if $parent eq "root";
  4142. }
  4143. elsif ($loc->{name} =~ /(.*)-[0-9A-Za-z]+/) { $parent = $1; }
  4144. $loc->{parent} = $parent || "";
  4145. }
  4146. # load per-locale XML files
  4147. foreach my $loc (@locales)
  4148. {
  4149. next if defined $loc->{alias};
  4150. (my $file = $loc->{file} || $loc->{name}) =~ s/-/_/g;
  4151. $file = "$base/" . ($loc->{dir} || "common") . "/main/$file.xml";
  4152. my $xml = load_xml_data_file( $CLDRDATA, $file );
  4153. $loc->{xml} = $xml;
  4154. $loc->{language} ||= xml_query( $xml, "/ldml/identity/language/\@type" );
  4155. $loc->{territory} ||= xml_query( $xml, "/ldml/identity/territory/\@type" );
  4156. $loc->{script} = xml_query( $xml, "/ldml/identity/script/\@type" );
  4157. if (!defined($loc->{territory}) && $loc->{name} =~ /-([A-Z]{2}|[0-9]{3})$/) { $loc->{territory} = $1; }
  4158. if (!defined($loc->{script}) && $loc->{name} =~ /-([A-Z][a-z]{3})(-[A-Z]{2})?$/) { $loc->{script} = $1; }
  4159. }
  4160. # assign a default territory and sort locale
  4161. foreach my $loc (@locales)
  4162. {
  4163. next if defined $loc->{alias};
  4164. next if defined $loc->{territory};
  4165. my $id = $loc->{sortlocale};
  4166. if (defined $id && ($id =~ /[-_]([A-Z0-9]+)$/))
  4167. {
  4168. $loc->{territory} = $1;
  4169. next;
  4170. }
  4171. my @children = grep /^$loc->{name}-[A-Z0-9]+$/ && !defined $lcnames{$_}->{alias}, keys %lcnames;
  4172. if (@children == 1)
  4173. {
  4174. $id = $children[0];
  4175. }
  4176. else
  4177. {
  4178. my $name = $loc->{file} || $loc->{name};
  4179. $name =~ s/-(Arab|Cyrl|Deva|Guru|Hans|Hant|Latn|Tfng|Vaii)$//;
  4180. $name =~ s/-/_/g;
  4181. $id = xml_query( $subtags, "/supplementalData/likelySubtags/likelySubtag[\@from='$name']/\@to" );
  4182. $id =~ s/_/-/g if $id;
  4183. }
  4184. if ($id =~ /[-_]([A-Z0-9]+)$/)
  4185. {
  4186. $loc->{territory} = $1;
  4187. next if defined $loc->{sortlocale};
  4188. next unless $id =~ /^$loc->{name}/;
  4189. while (defined $lcnames{$id} && defined $lcnames{$id}->{alias}) { $id = $lcnames{$id}->{alias}; }
  4190. $loc->{sortlocale} = $id if defined $lcnames{$id};
  4191. next;
  4192. }
  4193. print STDERR "no territory found for $loc->{name}\n";
  4194. }
  4195. # fill geoid table
  4196. my %geotable;
  4197. foreach my $geo (@geoids)
  4198. {
  4199. my $name = $geo->{name};
  4200. next unless defined $name;
  4201. $geo->{alias} = $geotable{$name} if defined $geotable{$name};
  4202. $geotable{$name} ||= $geo;
  4203. }
  4204. foreach my $loc (@locales)
  4205. {
  4206. next if defined $loc->{alias};
  4207. my $territory = $loc->{territory};
  4208. $geotable{$territory} ||= { name => $territory };
  4209. }
  4210. foreach my $name (keys %geotable)
  4211. {
  4212. my $geo = $geotable{$name};
  4213. $geo->{dialcode} = xml_query( $phone, "(/supplementalData/telephoneCodeData/codesByTerritory[\@territory='$name']/telephoneCountryCode)[1]/\@code" );
  4214. if ($name =~ /\d+/)
  4215. {
  4216. $geo->{uncode} = $name;
  4217. next;
  4218. }
  4219. $geo->{iso2} = $name;
  4220. $geo->{iso3} = xml_query( $suppl, "/supplementalData/codeMappings/territoryCodes[\@type='$name']/\@alpha3");
  4221. $geo->{uncode} = xml_query( $suppl, "/supplementalData/codeMappings/territoryCodes[\@type='$name']/\@numeric");
  4222. $geo->{sintlsymbol} ||= xml_query( $suppl, "(/supplementalData/currencyData/region[\@iso3166='$name']/currency[not(\@to)])[1]/\@iso4217") || "XXX";
  4223. $geo->{sintlsymbol} =~ s/XXX/XDR/;
  4224. }
  4225. foreach my $geo (@geoids)
  4226. {
  4227. $geo->{parentid} = $geotable{$geo->{parent}}->{id} if defined $geo->{parent};
  4228. next if defined $geo->{iso2};
  4229. next if defined $geo->{alias};
  4230. next unless defined $geo->{uncode};
  4231. my @contains;
  4232. my $list = xml_query( $suppl, "/supplementalData/territoryContainment/group[\@type='$geo->{uncode}' and not(\@status)]/\@contains");
  4233. push @contains, split /\s+/, $list if defined $list;
  4234. $list = xml_query( $suppl, "/supplementalData/territoryContainment/group[\@type='$geo->{uncode}' and \@status='deprecated']/\@contains");
  4235. push @contains, split /\s+/, $list if defined $list;
  4236. while (@contains)
  4237. {
  4238. my $territory = pop @contains;
  4239. if (defined $geotable{$territory})
  4240. {
  4241. $geotable{$territory}->{parentid} ||= $geo->{id};
  4242. }
  4243. elsif ($territory =~ /\d+/)
  4244. {
  4245. # expand region recursively
  4246. $list = xml_query( $suppl, "/supplementalData/territoryContainment/group[\@type='$territory' and not(\@status)]/\@contains" );
  4247. push @contains, split /\s+/, $list if defined $list;
  4248. }
  4249. }
  4250. }
  4251. # assign calendars to their locale
  4252. foreach my $cal (@calendars)
  4253. {
  4254. next unless defined $cal->{locale};
  4255. my $loc = $lcnames{$cal->{locale}};
  4256. $loc->{calendar} = [ ] unless defined $loc->{calendar};
  4257. push @{$loc->{calendar}}, $cal;
  4258. }
  4259. # assign default lcid to aliases
  4260. foreach my $loc (@locales)
  4261. {
  4262. next unless defined $loc->{alias};
  4263. next if defined $loc->{lcid};
  4264. my $alias = $loc->{alias};
  4265. my $lcid = $lcnames{$alias}->{lcid} || 0x1000;
  4266. $loc->{lcid} = $lcid | 0x80000000;
  4267. }
  4268. # assign sort aliases to parent locale
  4269. foreach my $loc (@locales)
  4270. {
  4271. next unless $loc->{name} =~ /_/;
  4272. next unless defined $loc->{alias};
  4273. my $alias = $loc->{alias};
  4274. my $parent = $lcnames{$alias};
  4275. my $basename = $parent->{name};
  4276. while (1)
  4277. {
  4278. @{$parent->{sortnames}}[($loc->{lcid} >> 16) - 1] = $loc->{name};
  4279. $alias = locale_parent( $alias );
  4280. last unless $alias && defined $lcnames{$alias};
  4281. $parent = $lcnames{$alias};
  4282. last if defined $parent->{sortbase} && $parent->{sortbase} ne $basename;
  4283. $parent->{sortbase} = $basename;
  4284. }
  4285. }
  4286. # assign an array index to all locales
  4287. my $idx = 0;
  4288. foreach my $loc (@locales)
  4289. {
  4290. next if defined $loc->{alias};
  4291. $loc->{idx} = $idx++;
  4292. }
  4293. foreach my $loc (@locales)
  4294. {
  4295. my $alias = $loc->{alias};
  4296. next unless defined $alias;
  4297. while (defined $lcnames{$alias}->{alias}) { $alias = $lcnames{$alias}->{alias}; }
  4298. $loc->{idx} = $lcnames{$alias}->{idx};
  4299. }
  4300. # output lcids table
  4301. my $lcid_data = "";
  4302. foreach my $id (sort { $a <=> $b } keys %lcids)
  4303. {
  4304. my $loc = $lcids{$id};
  4305. $lcid_data .= pack "L<S<2", $id, $loc->{idx}, add_string($loc->{name});
  4306. }
  4307. # output lcnames table
  4308. my $lcname_data = "";
  4309. foreach my $name (sort compare_locales keys %lcnames)
  4310. {
  4311. my $loc = $lcnames{$name};
  4312. $lcname_data .= pack "S<2L<", add_string($name), $loc->{idx}, $loc->{lcid} || 0x1000;
  4313. }
  4314. # output locales array
  4315. my $locale_data = "";
  4316. my $default_lcid = 0x8001;
  4317. foreach my $loc (@locales)
  4318. {
  4319. next if defined $loc->{alias};
  4320. my $sname = $loc->{name};
  4321. my $language = $loc->{language};
  4322. my $territory = $loc->{territory};
  4323. my $script = $loc->{script};
  4324. my $neutral = ($sname && $sname !~ /-$territory/);
  4325. my $sparent = $loc->{sparent} || (($sname =~ /(.*)-[0-9A-Za-z]+/) ? $1 : $loc->{parent});
  4326. my $unique_lcid = $loc->{lcid};
  4327. unless (defined $unique_lcid) { $unique_lcid = $default_lcid++; }
  4328. my $geo = $geotable{$territory};
  4329. my $territory_match = "contains(concat(' ',normalize-space(\@territories),' '),' $territory ')";
  4330. # languages and scripts
  4331. my $ssortlocale = $loc->{sortlocale} || ($neutral ? "$sname-$territory" : $sname);
  4332. my $idefaultlanguage = defined $lcnames{$ssortlocale} ? $lcnames{$ssortlocale}->{lcid} : undef;
  4333. $idefaultlanguage = $lcnames{"en-US"}->{lcid} unless $ssortlocale;
  4334. (my $siso639langname = $sname) =~ s/-.*$//;
  4335. my $siso639langname2 = $iso639{$siso639langname} || $siso639langname;
  4336. my $sopentypelang = sprintf "%-4s", locale_entry( $loc, "sopentypelang", uc $siso639langname2 );
  4337. my $sabbrevlangname = defined $loc->{lcid} ? locale_entry( $loc, "sabbrevlangname", uc $siso639langname2 ) : "ZZZ";
  4338. my $siso3166ctryname2 = $geo->{iso3} || $geo->{uncode};
  4339. my $senglanguage = loc_query( $lcnames{en}, "/ldml/localeDisplayNames/languages/language[\@type='$language' and not(\@alt)]" ) || "";
  4340. my $sengcountry = loc_query( $lcnames{en}, "/ldml/localeDisplayNames/territories/territory[\@type='$territory' and not(\@alt)]" ) || "";
  4341. my $snativelangname = loc_query( $loc, "/ldml/localeDisplayNames/languages/language[\@type='$language' and not(\@alt)]" );
  4342. my $snativectryname = loc_query( $loc, "/ldml/localeDisplayNames/territories/territory[\@type='$territory' and not(\@alt)]" );
  4343. $sengcountry =~ s/South Korea/Korea/;
  4344. $snativelangname ||= $senglanguage;
  4345. $snativectryname ||= $sengcountry;
  4346. if ($script)
  4347. {
  4348. my $engscript = loc_query( $lcnames{en}, "/ldml/localeDisplayNames/scripts/script[\@type='$script' and not(\@alt)]" );
  4349. my $nativescript = loc_query( $loc, "/ldml/localeDisplayNames/scripts/script[\@type='$script' and not(\@alt)]" );
  4350. $senglanguage .= " ($engscript)" if $engscript;
  4351. $snativelangname .= " ($nativescript)" if $nativescript;
  4352. }
  4353. my $sengdisplayname = $neutral ? $senglanguage : "$senglanguage ($sengcountry)";
  4354. my $snativedisplayname = $neutral ? $snativelangname : "$snativelangname ($snativectryname)";
  4355. $sengdisplayname =~ s/\) \(/, /;
  4356. $snativedisplayname =~ s/\) \(/, /;
  4357. my $sscripts = locale_entry( $loc, "sscripts", $script ) || xml_query( $suppl, "/supplementalData/languageData/language[\@type='$language' and not(\@alt)]/\@scripts" );
  4358. $sscripts = (join ";", (sort split / /, ($sscripts || "Latn"))) . ";";
  4359. my $ireadinglayout = locale_entry( $loc, "ireadinglayout", 0 );
  4360. my $charlayout = loc_query( $loc, "/ldml/layout/orientation/characterOrder" );
  4361. if ($charlayout eq "right-to-left")
  4362. {
  4363. $ireadinglayout = 1;
  4364. }
  4365. elsif ($charlayout eq "top-to-bottom")
  4366. {
  4367. my $linelayout = loc_query( $loc, "/ldml/layout/orientation/lineOrder" );
  4368. $ireadinglayout = $linelayout eq "right-to-left" ? 2 : 3;
  4369. }
  4370. my $igeoid = $geo->{id} || 0;
  4371. # numbers
  4372. my $sdecimal = loc_query( $loc, "/ldml/numbers/symbols[\@numberSystem='latn']/decimal" );
  4373. my $slist = locale_entry( $loc, "slist", ";" );
  4374. my $smondecimalsep = loc_query( $loc, "/ldml/numbers/symbols[\@numberSystem='latn']/currencyDecimal" ) || $sdecimal;
  4375. my $sthousand = loc_query( $loc, "/ldml/numbers/symbols[\@numberSystem='latn']/group" );
  4376. $sthousand =~ s/\x{202f}/\x{00a0}/;
  4377. my $smonthousandsep = loc_query( $loc, "/ldml/numbers/symbols[\@numberSystem='latn']/currencyGroup" ) || $sthousand;
  4378. my $spositivesign = "";
  4379. my $snegativesign = loc_query( $loc, "/ldml/numbers/symbols[\@numberSystem='latn']/minusSign" );
  4380. my $spercent = loc_query( $loc, "/ldml/numbers/symbols[\@numberSystem='latn']/percentSign" );
  4381. my $snan = loc_query( $loc, "/ldml/numbers/symbols[\@numberSystem='latn']/nan" );
  4382. my $sposinfinity = loc_query( $loc, "/ldml/numbers/symbols[\@numberSystem='latn']/infinity" );
  4383. my $sneginfinity = $sposinfinity ? "-$sposinfinity" : "";
  4384. my $sgrouping = format_to_grouping( loc_query( $loc, "/ldml/numbers/decimalFormats[\@numberSystem='latn']/decimalFormatLength[not(\@type)]/decimalFormat/pattern" ));
  4385. my $percentformat = loc_query( $loc, "/ldml/numbers/percentFormats[\@numberSystem='latn']/percentFormatLength[not(\@type)]/percentFormat/pattern" );
  4386. my $currencyformat = loc_query( $loc, "/ldml/numbers/currencyFormats[\@numberSystem='latn']/currencyFormatLength[not(\@type)]/currencyFormat[\@type='accounting']/pattern" ) ||
  4387. loc_query( $loc, "/ldml/numbers/currencyFormats[\@numberSystem='latn']/currencyFormatLength[not(\@type)]/currencyFormat[\@type='standard']/pattern" );
  4388. my $smongrouping = format_to_grouping( $currencyformat );
  4389. my ($icurrency, $inegcurr) = parse_currency_format( $sname, $currencyformat );
  4390. my ($ipospercent, $inegpercent) = parse_percent_format( $percentformat );
  4391. my $native_numbering = loc_query( $loc, "/ldml/numbers/otherNumberingSystems/native" );
  4392. my @snativedigits = split //, xml_query( $numbers, "/supplementalData/numberingSystems/numberingSystem[\@id='$native_numbering']/\@digits" );
  4393. my $digitsubstitution = !(ord($snativedigits[0]) >= 0x600 && ord($snativedigits[0]) <= 0x6ff);
  4394. my $measure = defined xml_query( $suppl, "/supplementalData/measurementData/measurementSystem[\@type='US' and $territory_match]" );
  4395. my $papersize = defined xml_query( $suppl, "/supplementalData/measurementData/paperSize[\@type='US-Letter' and $territory_match]" );
  4396. # currencies
  4397. my $sintlsymbol = $geo->{sintlsymbol} || "XDR";
  4398. my $scurrency = $geo->{scurrency} || loc_query( $loc, "/ldml/numbers/currencies/currency[\@type='$sintlsymbol']/symbol[\@alt='narrow']" );
  4399. $scurrency ||= loc_query( $loc, "/ldml/numbers/currencies/currency[\@type='$sintlsymbol']/symbol[not(\@alt)]" );
  4400. $geo->{scurrency} = $scurrency if $scurrency;
  4401. $scurrency ||= $sintlsymbol;
  4402. my $sengcurrname = $loc->{sengcurrname} || loc_query( $lcnames{en}, "/ldml/numbers/currencies/currency[\@type='$sintlsymbol']/displayName[not(\@count)]" );
  4403. my $snativecurrname = $loc->{sengcurrname} || loc_query( $loc, "/ldml/numbers/currencies/currency[\@type='$sintlsymbol']/displayName[not(\@count)]" ) || $sengcurrname;
  4404. my $icurrdigits = xml_query( $suppl, "/supplementalData/currencyData/fractions/info[\@iso4217='$sintlsymbol']/\@digits" );
  4405. $icurrdigits = 2 unless defined $icurrdigits;
  4406. # calendars
  4407. my $firstday = xml_query( $suppl, "/supplementalData/weekData/firstDay[not(\@alt) and $territory_match]/\@day" );
  4408. my $ifirstdayofweek = $firstday ? $days{$firstday} : 1;
  4409. my $firstweekofyear = (xml_query( $suppl, "/supplementalData/weekData/minDays[$territory_match]/\@count" ) || 0) == 4 ? 2 : 0;
  4410. my $serastring = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/eras/eraAbbr/era[\@type='1' and not(\@alt)]" );
  4411. my (@sdayname, @sabbrevdayname, @sshortestdayname);
  4412. foreach my $d (sort { $days{$a} <=> $days{$b} } keys %days)
  4413. {
  4414. my $n = $days{$d};
  4415. my %name;
  4416. foreach my $type (qw(wide abbreviated short))
  4417. {
  4418. $name{$type} = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/days/dayContext[\@type='format']/dayWidth[\@type='$type']/day[\@type='$d' and not(\@alt)]" );
  4419. }
  4420. push @sdayname, $name{wide};
  4421. push @sabbrevdayname, $name{abbreviated} || $name{wide};
  4422. push @sshortestdayname, $name{short} || $name{abbreviated} || $name{wide};
  4423. }
  4424. my (@smonthname, @sabbrevmonthname, @sgenitivemonth, @sabbrevgenitivemonth);
  4425. foreach my $n (1..13)
  4426. {
  4427. my $name = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/months/monthContext[\@type='stand-alone']/monthWidth[\@type='wide']/month[\@type='$n']" );
  4428. my $abbrev = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/months/monthContext[\@type='stand-alone']/monthWidth[\@type='abbreviated']/month[\@type='$n']" );
  4429. my $genitive = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/months/monthContext[\@type='format']/monthWidth[\@type='wide']/month[\@type='$n']" );
  4430. my $abbrevgen = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/months/monthContext[\@type='format']/monthWidth[\@type='abbreviated']/month[\@type='$n']" );
  4431. push @smonthname, $name || $genitive || "";
  4432. push @sabbrevmonthname, $abbrev || $abbrevgen || $name || $genitive || "";
  4433. push @sgenitivemonth, $genitive || "";
  4434. push @sabbrevgenitivemonth, $abbrevgen || $genitive || "";
  4435. }
  4436. @sgenitivemonth = () if join("|",@smonthname) eq join("|",@sgenitivemonth);
  4437. @sabbrevgenitivemonth = () if join("|",@sabbrevmonthname) eq join("|",@sabbrevgenitivemonth);
  4438. my %caltypes = ( "gregorian" => 1, "japanese" => 3, "chinese" => 4, "dangi" => 5, "islamic" => 6, "buddhist" => 7, "hebrew" => 8,
  4439. "persian" => 22, "islamic-civil" => 23, "islamic-umalqura" => 23 );
  4440. my $calpref = xml_query( $suppl, "/supplementalData/calendarPreferenceData/calendarPreference[$territory_match]/\@ordering" ) || "gregorian";
  4441. my $icalendartype;
  4442. my @scalnames;
  4443. foreach my $c (split /\s+/, $calpref)
  4444. {
  4445. next unless defined $caltypes{$c};
  4446. $icalendartype .= chr($caltypes{$c});
  4447. $scalnames[$caltypes{$c} - 1] = loc_query( $loc, "/ldml/localeDisplayNames/types/type[\@key='calendar' and \@type='$c']" );
  4448. }
  4449. # date/time formats
  4450. my $s1159 = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dayPeriods/dayPeriodContext[\@type='format']/dayPeriodWidth[\@type='abbreviated']/dayPeriod[\@type='am' and not(\@alt)]" );
  4451. my $s2359 = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dayPeriods/dayPeriodContext[\@type='format']/dayPeriodWidth[\@type='abbreviated']/dayPeriod[\@type='pm' and not (\@alt)]" );
  4452. my $sshortestam = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dayPeriods/dayPeriodContext[\@type='format']/dayPeriodWidth[\@type='narrow']/dayPeriod[\@type='am' and not(\@alt)]" );
  4453. my $sshortestpm = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dayPeriods/dayPeriodContext[\@type='format']/dayPeriodWidth[\@type='narrow']/dayPeriod[\@type='pm' and not (\@alt)]" );
  4454. my @stimeformat = (loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/timeFormats/timeFormatLength[\@type='medium']/timeFormat/pattern[not(\@alt)]" ));
  4455. push @stimeformat, loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='Hms' and not(\@alt)]" );
  4456. pop @stimeformat if $stimeformat[0] eq $stimeformat[1];
  4457. @stimeformat = map convert_time_format($_), @stimeformat;
  4458. my @sshorttime = (loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/timeFormats/timeFormatLength[\@type='short']/timeFormat/pattern[not(\@alt)]" ));
  4459. push @sshorttime, loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='Hm' and not(\@alt)]" );
  4460. pop @sshorttime if $sshorttime[0] eq $sshorttime[1];
  4461. @sshorttime = map convert_time_format($_), @sshorttime;
  4462. my @sshortdate = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='yMd' and not(\@alt)]" );
  4463. push @sshortdate, loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='yMMMd' and not(\@alt)]" );
  4464. @sshortdate = map convert_date_format($_), @sshortdate;
  4465. my @slongdate = (loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateFormats/dateFormatLength[\@type='full']/dateFormat/pattern[not(\@alt)]" ));
  4466. push @slongdate, loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateFormats/dateFormatLength[\@type='long']/dateFormat/pattern[not(\@alt)]" );
  4467. @slongdate = map convert_date_format($_), @slongdate;
  4468. my @smonthday = (loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='MMMMd' and not(\@alt)]" ));
  4469. push @smonthday, loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='Md' and not(\@alt)]" );
  4470. push @smonthday, loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='MMMd' and not(\@alt)]" );
  4471. @smonthday = map convert_date_format($_), @smonthday;
  4472. my @syearmonth = map convert_date_format($_), loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='yMMMM' and not(\@alt)]" );
  4473. my @sduration = map convert_time_format( lc $_ ), loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='Hms' and not(\@alt)]" );
  4474. my $srelativelongdate = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='MMMMEd' and not(\@alt)]" ) ||
  4475. loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='gregorian']/dateTimeFormats/availableFormats/dateFormatItem[\@id='MMMEd' and not(\@alt)]" );
  4476. $srelativelongdate = convert_date_format( $srelativelongdate );
  4477. if (defined $loc->{calendar})
  4478. {
  4479. foreach my $cal (@{$loc->{calendar}})
  4480. {
  4481. $cal->{sshortdate} = \@sshortdate;
  4482. $cal->{syearmonth} = \@syearmonth;
  4483. $cal->{slongdate} = \@slongdate;
  4484. $cal->{serastring} = [ $serastring ];
  4485. $cal->{sdayname} = \@sdayname;
  4486. $cal->{sabbrevdayname} = \@sabbrevdayname;
  4487. $cal->{smonthname} = \@smonthname;
  4488. $cal->{sabbrevmonthname} = \@sabbrevmonthname;
  4489. $cal->{scalname} = $scalnames[$cal->{id}];
  4490. $cal->{smonthday} = \@smonthday;
  4491. $cal->{sshortestdayname} = \@sshortestdayname;
  4492. $cal->{sabbreverastring} = [ $serastring ];
  4493. $cal->{sshortestdayname} = \@sshortestdayname;
  4494. $cal->{srelativelongdate} = $srelativelongdate;
  4495. }
  4496. }
  4497. # codepages
  4498. my %ansicpmap = ( 437 => 1252, 720 => 1256, 737 => 1253, 775 => 1257, 850 => 1252,
  4499. 852 => 1250, 855 => 1251, 866 => 1251, 857 => 1254, 862 => 1255 );
  4500. my %maccpmap = ( 437 => 10000, 720 => 10004, 737 => 10006, 775 => 10029, 850 => 10000,
  4501. 852 => 10029, 855 => 10007, 857 => 10081, 862 => 10005, 866 => 10007,
  4502. 874 => 10021, 932 => 10001, 936 => 10008, 949 => 10003, 950 => 10002,
  4503. 1258 => 10000 );
  4504. my %ebcdiccpmap = ( 437 => 37, 720 => 20420, 737 => 20273, 866 => 20880, 932 => 20290 );
  4505. my %codepagemasks = ( 874 => [ 0x01000000, 0x00000000, 0x00000000, 0, 0x00010000, 0x00000000, 0x00010000, 0x00000000 ],
  4506. 932 => [ 0x00000000, 0x28c70000, 0x00000010, 0, 0x00020000, 0x00000000, 0x00020000, 0x00000000 ],
  4507. 936 => [ 0x00000000, 0x28010000, 0x00000002, 0, 0x00040000, 0x00000000, 0x00040000, 0x00000000 ],
  4508. 949 => [ 0x00000000, 0x00000000, 0x00000000, 0, 0x00080000, 0x00000000, 0x00080000, 0x00000000 ],
  4509. 950 => [ 0x00000000, 0x28c10000, 0x00000012, 0, 0x00100000, 0x00000000, 0x00100000, 0x00000000 ],
  4510. 1258 => [ 0x2000000f, 0x00000000, 0x00000000, 0, 0x00000100, 0x00008000, 0x00000100, 0x00008000 ],
  4511. 866 => [ 0x00000200, 0x00000000, 0x00000000, 0, 0x00000004, 0x00020000, 0x00000004, 0x02020000 ],
  4512. 862 => [ 0x00000800, 0x40000000, 0x00000000, 0, 0x00000020, 0x00200000, 0x00000020, 0x00200000 ],
  4513. 857 => [ 0x0000001f, 0x00000000, 0x00000000, 0, 0x00000010, 0x01000000, 0x00000010, 0x01000000 ],
  4514. 855 => [ 0x00000200, 0x00000000, 0x00000000, 0, 0x00000004, 0x02000000, 0x00000004, 0x02000000 ],
  4515. 852 => [ 0x00000027, 0x00000000, 0x00000000, 0, 0x00000002, 0x04000000, 0x00000002, 0x04000000 ],
  4516. 775 => [ 0x00000007, 0x00000000, 0x00000000, 0, 0x00000080, 0x08000000, 0x00000080, 0x08000000 ],
  4517. 737 => [ 0x00000080, 0x00000000, 0x00000000, 0, 0x00000008, 0x10000000, 0x00000008, 0x10010000 ],
  4518. 720 => [ 0x00002000, 0x00000000, 0x00000000, 0, 0x00000040, 0x20000000, 0x00000040, 0x20080000 ],
  4519. 850 => [ 0x00000003, 0x00000000, 0x00000000, 0, 0x00000001, 0x40000000, 0x0000019f, 0xdfd70000 ],
  4520. 437 => [ 0x00000003, 0x00000000, 0x00000000, 0, 0x00000001, 0x80000000, 0x0000019f, 0xdfd70000 ],
  4521. 65001 => [ 0x00000000, 0x00000000, 0x00000000, 0, 0x00000000, 0x00000000, 0x0000019f, 0xdfd70000 ] );
  4522. my $oemcp = locale_entry( $loc, "oemcp", 65001 );
  4523. my $maccp = locale_entry( $loc, "maccp", undef ) || $maccpmap{$oemcp} || 65001;
  4524. my $ebcdiccp = locale_entry( $loc, "ebcdiccp", undef ) || $ebcdiccpmap{$oemcp} || 500;
  4525. $ebcdiccp = 500 if (defined $loc->{oemcp} && $loc->{oemcp} == 65001) || (defined $loc->{maccp} && $loc->{maccp} == 65001);
  4526. my $ansicp = $ansicpmap{$oemcp} || $oemcp;
  4527. my @fontsig = (0) x 8;
  4528. my $sig = locale_entry( $loc, "fontsig", [] );
  4529. foreach my $i (0..7) { $fontsig[$i] |= $codepagemasks{$oemcp}->[$i]; }
  4530. foreach my $i (0..$#{$sig}) { $fontsig[$i] |= $sig->[$i]; }
  4531. $fontsig[3] |= 1 << 31;
  4532. $fontsig[3] |= 1 << 27 if $ireadinglayout == 1;
  4533. $fontsig[3] |= 1 << 28 if $ireadinglayout == 3;
  4534. # special cases for invariant locale
  4535. unless ($loc->{name})
  4536. {
  4537. $siso639langname = "iv";
  4538. $siso639langname2 = "ivl";
  4539. $senglanguage = $snativelangname = "Invariant Language";
  4540. $sengcountry = $snativectryname = "Invariant Country";
  4541. $sengdisplayname = "Invariant Language (Invariant Country)";
  4542. $snativedisplayname = "Invariant Language (Invariant Region)";
  4543. $sengcurrname = $snativecurrname = "International Monetary Fund";
  4544. $scurrency = "\x{00a4}";
  4545. $ifirstdayofweek = 0;
  4546. $igeoid = $geotable{"US"}->{id};
  4547. @stimeformat = ("HH:mm:ss");
  4548. @sshortdate = ("MM/dd/yyyy", "yyyy-MM-dd");
  4549. @slongdate = ("dddd, dd MMMM yyyy");
  4550. @syearmonth = ("yyyy MMMM");
  4551. @smonthday = ("MMMM dd", "MMMM d", "M/d", "MMM d");
  4552. @sshorttime = ("HH:mm", "hh:mm tt", "H:mm", "h:mm tt");
  4553. $srelativelongdate = "dddd, MMMM dd";
  4554. $sposinfinity = "Infinity";
  4555. $sneginfinity = "-Infinity";
  4556. $spositivesign = "+";
  4557. $ipospercent = $inegpercent = 0;
  4558. }
  4559. # output data
  4560. $locale_data .= pack "L<2",
  4561. add_string( $sname ), # name
  4562. add_string( $sopentypelang ); # LOCALE_SOPENTYPELANGUAGETAG
  4563. $locale_data .= pack "S<14",
  4564. $loc->{lcid} || 0x1000, # LOCALE_ILANGUAGE
  4565. $unique_lcid, # unique_lcid
  4566. locale_entry( $loc, "idigits", 2 ), # LOCALE_IDIGITS
  4567. locale_entry( $loc, "inegnumber", 1 ), # LOCALE_INEGNUMBER
  4568. $icurrdigits, # LOCALE_ICURRDIGITS
  4569. $icurrency, # LOCALE_ICURRENCY
  4570. $inegcurr, # LOCALE_INEGCURR
  4571. locale_entry( $loc, "ilzero", 1 ), # LOCALE_ILZERO
  4572. !$neutral, # LOCALE_INEUTRAL
  4573. $ifirstdayofweek, # LOCALE_IFIRSTDAYOFWEEK
  4574. $firstweekofyear, # LOCALE_IFIRSTWEEKOFYEAR
  4575. $geo->{dialcode} || 1 , # LOCALE_ICOUNTRY,
  4576. $measure, # LOCALE_IMEASURE
  4577. $digitsubstitution; # LOCALE_IDIGITSUBSTITUTION
  4578. $locale_data .= pack "L<18",
  4579. add_string( $sgrouping ), # LOCALE_SGROUPING
  4580. add_string( $smongrouping ), # LOCALE_SMONGROUPING
  4581. add_string( $slist ), # LOCALE_SLIST
  4582. add_string( $sdecimal ), # LOCALE_SDECIMAL
  4583. add_string( $sthousand ), # LOCALE_STHOUSAND
  4584. add_string( $scurrency ), # LOCALE_SCURRENCY
  4585. add_string( $smondecimalsep ), # LOCALE_SMONDECIMALSEP
  4586. add_string( $smonthousandsep ), # LOCALE_SMONTHOUSANDSEP
  4587. add_string( $spositivesign ), # LOCALE_SPOSITIVESIGN
  4588. add_string( $snegativesign ), # LOCALE_SNEGATIVESIGN
  4589. add_string( $s1159 ), # LOCALE_S1159
  4590. add_string( $s2359 ), # LOCALE_S2359
  4591. add_strarray( @snativedigits ), # LOCALE_SNATIVEDIGITS
  4592. add_strarray( @stimeformat ), # LOCALE_STIMEFORMAT
  4593. add_strarray( @sshortdate ), # LOCALE_SSHORTDATE
  4594. add_strarray( @slongdate ), # LOCALE_SLONGDATE
  4595. add_strarray( @syearmonth ), # LOCALE_SYEARMONTH
  4596. add_strarray( @sduration ); # LOCALE_SDURATION
  4597. $locale_data .= pack "S<8",
  4598. $idefaultlanguage || 0x1000, # LOCALE_IDEFAULTLANGUAGE
  4599. $ansicp, # LOCALE_IDEFAULTANSICODEPAGE
  4600. $oemcp, # LOCALE_IDEFAULTCODEPAGE
  4601. $maccp, # LOCALE_IDEFAULTMACCODEPAGE
  4602. $ebcdiccp, # LOCALE_IDEFAULTEBCDICCODEPAGE
  4603. $igeoid < 65536 ? $igeoid : 39070, # old_geoid
  4604. $papersize ? 1 : 9, # LOCALE_IPAPERSIZE
  4605. 0; # FIXME # islamic_cal
  4606. $locale_data .= pack "L<24",
  4607. add_string( $icalendartype ), # LOCALE_ICALENDARTYPE
  4608. add_string( $sabbrevlangname ), # LOCALE_SABBREVLANGNAME
  4609. add_string( $siso639langname ), # LOCALE_SISO639LANGNAME
  4610. add_string( $senglanguage ), # LOCALE_SENGLANGUAGE
  4611. add_string( $snativelangname ), # LOCALE_SNATIVELANGNAME
  4612. add_string( $sengcountry ), # LOCALE_SENGCOUNTRY
  4613. add_string( $snativectryname ), # LOCALE_SNATIVECTRYNAME
  4614. add_string( $siso3166ctryname2 ), # LOCALE_SABBREVCTRYNAME
  4615. add_string( $territory ), # LOCALE_SISO3166CTRYNAME
  4616. add_string( $sintlsymbol ), # LOCALE_SINTLSYMBOL
  4617. add_string( $sengcurrname ), # LOCALE_SENGCURRNAME
  4618. add_string( $snativecurrname ), # LOCALE_SNATIVECURRNAME
  4619. add_fontsig( @fontsig ), # LOCALE_FONTSIGNATURE
  4620. add_string( $siso639langname2 ), # LOCALE_SISO639LANGNAME2
  4621. add_string( $siso3166ctryname2 ), # LOCALE_SISO3166CTRYNAME2
  4622. add_string( $sparent ), # LOCALE_SPARENT
  4623. add_strarray( @sdayname ), # LOCALE_SDAYNAME
  4624. add_strarray( @sabbrevdayname ), # LOCALE_SABBREVDAYNAME
  4625. add_strarray( @smonthname ), # LOCALE_SMONTHNAME
  4626. add_strarray( @sabbrevmonthname ), # LOCALE_SABBREVMONTHNAME
  4627. add_strarray( @sgenitivemonth ), # LOCALE_SGENITIVEMONTH
  4628. add_strarray( @sabbrevgenitivemonth ), # LOCALE_SABBREVGENITIVEMONTH
  4629. add_strarray( @scalnames ), # LOCALE_SCALNAMES
  4630. add_strarray( @{$loc->{sortnames}} ); # LOCALE_SSORTNAMES
  4631. $locale_data .= pack "S<6",
  4632. $inegpercent, # LOCALE_INEGATIVEPERCENT
  4633. $ipospercent, # LOCALE_IPOSITIVEPERCENT
  4634. 0, # unknown
  4635. $ireadinglayout, # LOCALE_IREADINGLAYOUT
  4636. 0x2a, # unknown
  4637. 0x2a; # unknown
  4638. $locale_data .= pack "L<24",
  4639. 0, # unknown
  4640. add_string( $sengdisplayname ), # LOCALE_SENGLISHDISPLAYNAME
  4641. add_string( $snativedisplayname ), # LOCALE_SNATIVEDISPLAYNAME
  4642. add_string( $spercent ), # LOCALE_SPERCENT
  4643. add_string( $snan ), # LOCALE_SNAN
  4644. add_string( $sposinfinity ), # LOCALE_SPOSINFINITY
  4645. add_string( $sneginfinity ), # LOCALE_SNEGINFINITY
  4646. 0, # unknown
  4647. add_string( $serastring ), # CAL_SERASTRING
  4648. add_string( $serastring ), # CAL_SABBREVERASTRING
  4649. 0, # unknown
  4650. add_string( $ssortlocale ), # LOCALE_SCONSOLEFALLBACKNAME
  4651. add_strarray( @sshorttime ), # LOCALE_SSHORTTIME
  4652. add_strarray( @sshortestdayname ), # CAL_SSHORTESTDAYNAME
  4653. 0, # unknown
  4654. add_string( $ssortlocale ), # LOCALE_SSORTLOCALE
  4655. add_string( "0409:00000409" ), # FIXME # LOCALE_SKEYBOARDSTOINSTALL
  4656. add_string( $sscripts ), # LOCALE_SSCRIPTS
  4657. add_string( $srelativelongdate ), # LOCALE_SRELATIVELONGDATE
  4658. $igeoid, # LOCALE_IGEOID
  4659. add_string( $sshortestam || "a" ), # LOCALE_SSHORTESTAM
  4660. add_string( $sshortestpm || "p" ), # LOCALE_SSHORTESTPM
  4661. add_strarray( @smonthday ), # LOCALE_SMONTHDAY
  4662. add_string( "k0-windows-us" ) # FIXME # keyboard_layout
  4663. }
  4664. # output language groups
  4665. my %groups;
  4666. add_registry_key( "Locale", "00000409" );
  4667. foreach my $loc (@locales)
  4668. {
  4669. next unless defined $loc->{lcid};
  4670. next if ($loc->{lcid} & 0x80000000);
  4671. next if !defined($loc->{alias}) && $loc->{name} !~ /-$loc->{territory}/; # skip neutral locales
  4672. my $group = locale_entry( $loc, "group", 1 );
  4673. my $name = sprintf( "%08x", $loc->{lcid} );
  4674. my $val = sprintf( "%x", $group );
  4675. add_registry_value( "Locale", $name, $val ) unless ($loc->{lcid} & 0x000f0000);
  4676. add_registry_value( "Locale\\Alternate Sorts", $name, $val ) if $loc->{name} =~ /_/;
  4677. $groups{$val} = 1;
  4678. }
  4679. foreach my $group (keys %groups) { add_registry_value( "Language Groups", $group, "1" ); }
  4680. # output calendar data
  4681. my $calendar_data = "";
  4682. foreach my $cal (@calendars)
  4683. {
  4684. my $scalname = $cal->{name};
  4685. my $iyearoffsetrange = 0;
  4686. my $itwodigityearmax = $cal->{itwodigityearmax};
  4687. my @sshortdate;
  4688. my @syearmonth;
  4689. my @slongdate;
  4690. my @serastring;
  4691. my @sdayname;
  4692. my @sabbrevdayname;
  4693. my @smonthname;
  4694. my @sabbrevmonthname;
  4695. my @smonthday;
  4696. my @sabbreverastring;
  4697. my @sshortestdayname;
  4698. my $type = $cal->{type};
  4699. if (defined $cal->{locale} && defined $type)
  4700. {
  4701. my $loc = $lcnames{$cal->{locale}};
  4702. my $fmt = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='$type']/dateTimeFormats/availableFormats/dateFormatItem[\@id='yMd' and not(\@alt)]" );
  4703. push @sshortdate, $fmt if $fmt;
  4704. $fmt = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='$type']/dateTimeFormats/availableFormats/dateFormatItem[\@id='yyyyMd' and not(\@alt)]" );
  4705. push @sshortdate, $fmt if $fmt;
  4706. $fmt = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='$type']/dateTimeFormats/availableFormats/dateFormatItem[\@id='yMMMd' and not(\@alt)]" );
  4707. push @sshortdate, $fmt if $fmt;
  4708. $fmt = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='$type']/dateTimeFormats/availableFormats/dateFormatItem[\@id='yyyyMMMd' and not(\@alt)]" );
  4709. push @sshortdate, $fmt if $fmt;
  4710. @sshortdate = map convert_date_format($_), @sshortdate;
  4711. $fmt = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='$type']/dateFormats/dateFormatLength[\@type='full']/dateFormat/pattern[not(\@alt)]" );
  4712. push @slongdate, $fmt if $fmt;
  4713. $fmt = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='$type']/dateFormats/dateFormatLength[\@type='long']/dateFormat/pattern[not(\@alt)]" );
  4714. push @slongdate, $fmt if $fmt;
  4715. @slongdate = map convert_date_format($_), @slongdate;
  4716. foreach my $n (1..13)
  4717. {
  4718. my $name = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='$type']/months/monthContext[\@type='format']/monthWidth[\@type='wide']/month[\@type='$n' and not(\@yeartype)]" );
  4719. my $abbrev = loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='$type']/months/monthContext[\@type='format']/monthWidth[\@type='abbreviated']/month[\@type='$n' and not(\@yeartype)]" );
  4720. push @smonthname, $name || "";
  4721. push @sabbrevmonthname, $abbrev || $name || "";
  4722. }
  4723. $scalname ||= loc_query( $loc, "/ldml/localeDisplayNames/types/type[\@key='calendar' and \@type='$type']" );
  4724. if (defined $cal->{eras})
  4725. {
  4726. my @eras;
  4727. my $idx = 1;
  4728. foreach my $era (@{$cal->{eras}})
  4729. {
  4730. my $start = xml_query( $suppl, "/supplementalData/calendarData/calendar[\@type='$type']/eras/era[\@type='$era']/\@start" );
  4731. next unless $start =~ /^(-?\d+)-(\d+)-(\d+)/;
  4732. my ($year, $mon, $day, $zero, $first) = ($1, $2, $3, $1 - 1, 1);
  4733. if ($zero < 0)
  4734. {
  4735. $first -= $zero;
  4736. $year = 1;
  4737. $itwodigityearmax = 2049 - $zero;
  4738. }
  4739. unshift @eras, pack( "S<8", 6, $idx++, $year, $mon, $day, $zero, $first, 0 );
  4740. push @serastring, loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='$type']/eras/eraAbbr/era[\@type='$era']" );
  4741. push @sabbreverastring, loc_query( $loc, "/ldml/dates/calendars/calendar[\@type='$type']/eras/eraNarrow/era[\@type='$era']" );
  4742. }
  4743. $iyearoffsetrange = add_str_data( pack "S<L<*", scalar @eras, map { add_str_data($_); } @eras );
  4744. }
  4745. }
  4746. @sshortdate = @{$cal->{sshortdate}} if defined $cal->{sshortdate} && !@sshortdate;
  4747. @syearmonth = @{$cal->{syearmonth}} if defined $cal->{syearmonth};
  4748. @slongdate = @{$cal->{slongdate}} if defined $cal->{slongdate} && !@slongdate;
  4749. @serastring = @{$cal->{serastring}} if defined $cal->{serastring} && !@serastring;
  4750. @sdayname = @{$cal->{sdayname}} if defined $cal->{sdayname};
  4751. @sabbrevdayname = @{$cal->{sabbrevdayname}} if defined $cal->{sabbrevdayname};
  4752. @smonthname = @{$cal->{smonthname}} if defined $cal->{smonthname} && !join("",@smonthname);
  4753. @sabbrevmonthname = @{$cal->{sabbrevmonthname}} if defined $cal->{sabbrevmonthname} && !join("",@sabbrevmonthname);
  4754. @smonthday = @{$cal->{smonthday}} if defined $cal->{smonthday};
  4755. @sabbreverastring = @{$cal->{sabbreverastring}} if defined $cal->{sabbreverastring} && !@sabbreverastring;
  4756. @sshortestdayname = @{$cal->{sshortestdayname}} if defined $cal->{sshortestdayname};
  4757. my $srelativelongdate = $cal->{srelativelongdate};
  4758. @serastring = ("A.D.") unless @serastring;
  4759. @sabbreverastring = ("AD") unless @sabbreverastring;
  4760. if ($cal->{id} != 1) # calendar 1 is a placeholder, information is fetched from locale instead
  4761. {
  4762. @sshortdate = ("") unless @sshortdate;
  4763. @syearmonth = ("") unless @syearmonth;
  4764. @slongdate = ("") unless @slongdate;
  4765. @sdayname = ("") x 7 unless @sdayname;
  4766. @sabbrevdayname = ("") x 7 unless @sabbrevdayname;
  4767. @sshortestdayname = ("") x 7 unless @sshortestdayname;
  4768. @smonthname = ("") x 13 unless @smonthname;
  4769. @sabbrevmonthname = ("") x 13 unless @sabbrevmonthname;
  4770. @smonthday = ("") unless @smonthday;
  4771. }
  4772. $calendar_data .= pack "S<2L<17",
  4773. $cal->{id}, # CAL_ICALINTVALUE
  4774. $itwodigityearmax || 99, # CAL_ITWODIGITYEARMAX
  4775. add_strarray( @sshortdate ), # CAL_SSHORTDATE
  4776. add_strarray( @syearmonth ), # CAL_SYEARMONTH
  4777. add_strarray( @slongdate ), # CAL_SLONGDATE
  4778. add_strarray( @serastring ), # CAL_SERASTRING
  4779. $iyearoffsetrange, # CAL_IYEAROFFSETRANGE
  4780. add_strarray( @sdayname ), # CAL_SDAYNAME
  4781. add_strarray( @sabbrevdayname ), # CAL_SABBREVDAYNAME
  4782. add_strarray( @smonthname ), # CAL_SMONTHNAME
  4783. add_strarray( @sabbrevmonthname ), # CAL_SABBREVMONTHNAME
  4784. add_string( $scalname ), # CAL_SCALNAME
  4785. add_strarray( @smonthday ), # CAL_SMONTHDAY
  4786. add_strarray( @sabbreverastring ), # CAL_SABBREVERASTRING
  4787. add_strarray( @sshortestdayname ), # CAL_SSHORTESTDAYNAME
  4788. add_string( $srelativelongdate ); # CAL_SRELATIVELONGDATE
  4789. }
  4790. # output locale header
  4791. my $nb_lcids = scalar keys %lcids;
  4792. my $nb_locales = scalar grep { !defined $_->{alias} } @locales;
  4793. my $nb_lcnames = scalar keys %lcnames;
  4794. my $locale_size = length($locale_data) / $nb_locales;
  4795. my $nb_calendars = scalar @calendars;
  4796. my $calendar_size = length($calendar_data) / $nb_calendars;
  4797. my $lcids_offset = 19 * 4; # size of header
  4798. my $lcnames_offset = $lcids_offset + length $lcid_data;
  4799. my $locales_offset = $lcnames_offset + length $lcname_data;
  4800. my $calendar_offset = $locales_offset + length $locale_data;
  4801. my $strings_offset = $calendar_offset + length $calendar_data;
  4802. my $locale_header = pack "L<7S<4L<S<2L<3S<2L<4",
  4803. 8, # offset
  4804. 0,
  4805. 7, # version
  4806. 0x5344534e, # magic
  4807. 0, 0, 0,
  4808. 0,
  4809. $nb_lcids,
  4810. $nb_locales,
  4811. $locale_size,
  4812. $locales_offset,
  4813. $nb_lcnames,
  4814. 0,
  4815. $lcids_offset,
  4816. $lcnames_offset,
  4817. 0,
  4818. $nb_calendars,
  4819. $calendar_size,
  4820. $calendar_offset,
  4821. $strings_offset,
  4822. 0, 0;
  4823. return align_string( 4, $locale_header . $lcid_data . $lcname_data . $locale_data . $calendar_data . $string_data );
  4824. }
  4825. ################################################################
  4826. # build the geoids table for locale.nls
  4827. sub build_geoids_data()
  4828. {
  4829. my $data = "";
  4830. my %index;
  4831. my $idx = 0;
  4832. my @geo_header = (0x00650067, 0x0000006f, 0, 4 * 7, scalar @geoids, 0, 0);
  4833. foreach my $geo (@geoids)
  4834. {
  4835. my $id = $geo->{id};
  4836. $geo = $geo->{alias} if defined $geo->{alias};
  4837. my $lat = "0.000";
  4838. my $long = "0.000";
  4839. my $iso2 = $geo->{iso2} || "XX";
  4840. my $iso3 = $geo->{iso3} || "XX";
  4841. my $isregion = $geo->{region} || (defined $geo->{uncode} && !defined $geo->{iso2});
  4842. my $sintlsymbol = $geo->{sintlsymbol} || "XDR";
  4843. my $scurrency = $geo->{scurrency} || "\x{00a4}";
  4844. $data .= pack( "L<", $id );
  4845. $data .= pad_string( 24, encode( "UTF16LE", $lat ));
  4846. $data .= pad_string( 24, encode( "UTF16LE", $long ));
  4847. $data .= pack( "L<2", $isregion ? 14 : 16, $geo->{parentid} || 39070 );
  4848. $data .= pad_string( 8, encode( "UTF16LE", $iso2 ));
  4849. $data .= pad_string( 8, encode( "UTF16LE", $iso3 ));
  4850. $data .= pack( "S<2", $geo->{uncode} || 0, $geo->{dialcode} || 0 );
  4851. $data .= pad_string( 8, encode( "UTF16LE", $sintlsymbol ));
  4852. $data .= pad_string( 16, encode( "UTF16LE", $scurrency ));
  4853. $index{$geo->{name}} = $idx if $geo->{name};
  4854. $idx++;
  4855. }
  4856. $index{"XX"} = $index{"001"};
  4857. $geo_header[5] = $geo_header[3] + length $data;
  4858. $geo_header[6] = scalar keys %index;
  4859. foreach my $name (sort keys %index)
  4860. {
  4861. $data .= pad_string( 8, encode( "UTF16LE", $name ));
  4862. $data .= pack "L<", $index{$name};
  4863. }
  4864. $geo_header[2] = $geo_header[3] + length $data;
  4865. return pack( "L<7", @geo_header ) . $data;
  4866. }
  4867. ################################################################
  4868. # build a binary locale table
  4869. sub dump_locales($$)
  4870. {
  4871. my ($filename, $chartypes) = @_;
  4872. printf "Building $filename\n";
  4873. my $locale_data = build_locale_data();
  4874. my $charmaps_data = ""; # FIXME
  4875. my $geoids_data = build_geoids_data();
  4876. my $scripts_data = ""; # FIXME
  4877. my @header = ( 0 ) x 8;
  4878. $header[0] = 4 * scalar @header; # chartypes offset
  4879. $header[4] = $header[0] + length $chartypes; # locales offset
  4880. $header[5] = $header[4] + length $locale_data; # charmaps offset
  4881. $header[6] = $header[5] + length $charmaps_data; # geoids offset
  4882. $header[7] = $header[6] + length $geoids_data; # scripts offset
  4883. open OUTPUT, ">$filename.new" or die "Cannot create $filename";
  4884. print OUTPUT pack "L<*", @header;
  4885. print OUTPUT $chartypes, $locale_data, $charmaps_data, $geoids_data, $scripts_data;
  4886. close OUTPUT;
  4887. save_file($filename);
  4888. }
  4889. ################################################################
  4890. # build the script to create registry keys
  4891. sub dump_registry_script($%)
  4892. {
  4893. my ($filename, %keys) = @_;
  4894. my $indent = 1;
  4895. printf "Building %s\n", $filename;
  4896. open OUTPUT, ">$filename.new" or die "Cannot create $filename";
  4897. print OUTPUT "HKLM\n{\n";
  4898. foreach my $k (split /\\/, "SYSTEM\\CurrentControlSet\\Control\\Nls")
  4899. {
  4900. printf OUTPUT "%*sNoRemove %s\n%*s{\n", 4 * $indent, "", $k, 4 * $indent, "";
  4901. $indent++;
  4902. }
  4903. foreach my $k (sort keys %keys)
  4904. {
  4905. my @subkeys = split /\\/, $k;
  4906. my ($def, @vals) = @{$keys{$k}};
  4907. for (my $i = 0; $i < @subkeys; $i++)
  4908. {
  4909. printf OUTPUT "%*s%s%s\n%*s{\n", 4 * $indent, "",
  4910. $subkeys[$i] =~ /\s/ ? "'$subkeys[$i]'" : $subkeys[$i],
  4911. $i == $#subkeys && $def ? " = s '$def'" : "", 4 * $indent, "";
  4912. $indent++;
  4913. }
  4914. foreach my $v (sort @vals) { printf OUTPUT "%*sval $v\n", 4 * $indent, ""; }
  4915. for (my $i = 0; $i < @subkeys; $i++) { printf OUTPUT "%*s}\n", 4 * --$indent, ""; }
  4916. }
  4917. while ($indent) { printf OUTPUT "%*s}\n", 4 * --$indent, ""; }
  4918. close OUTPUT;
  4919. save_file($filename);
  4920. }
  4921. ################################################################
  4922. # save a file if modified
  4923. sub save_file($)
  4924. {
  4925. my $file = shift;
  4926. if (-f $file && !system "cmp $file $file.new >/dev/null")
  4927. {
  4928. unlink "$file.new";
  4929. }
  4930. else
  4931. {
  4932. rename "$file.new", "$file";
  4933. }
  4934. }
  4935. ################################################################
  4936. # main routine
  4937. chdir ".." if -f "./make_unicode";
  4938. load_data();
  4939. dump_sortkeys( "dlls/kernelbase/collation.c" );
  4940. dump_bidi_dir_table( "dlls/gdi32/uniscribe/direction.c" );
  4941. dump_bidi_dir_table( "dlls/dwrite/direction.c" );
  4942. dump_digit_folding( "dlls/kernelbase/digitmap.c" );
  4943. dump_mirroring( "dlls/gdi32/uniscribe/mirror.c" );
  4944. dump_mirroring( "dlls/dwrite/mirror.c" );
  4945. dump_bracket( "dlls/gdi32/uniscribe/bracket.c" );
  4946. dump_bracket( "dlls/dwrite/bracket.c" );
  4947. dump_shaping( "dlls/gdi32/uniscribe/shaping.c" );
  4948. dump_arabic_shaping( "dlls/dwrite/shapers/arabic_table.c" );
  4949. dump_linebreak( "dlls/gdi32/uniscribe/linebreak.c" );
  4950. dump_linebreak( "dlls/dwrite/linebreak.c" );
  4951. dump_scripts( "dlls/dwrite/scripts" );
  4952. dump_indic( "dlls/gdi32/uniscribe/indicsyllable.c" );
  4953. dump_vertical( "dlls/win32u/vertical.c", 1 );
  4954. dump_vertical( "dlls/wineps.drv/vertical.c", 0 );
  4955. dump_intl_nls("nls/l_intl.nls");
  4956. dump_norm_table( "nls/normnfc.nls" );
  4957. dump_norm_table( "nls/normnfd.nls" );
  4958. dump_norm_table( "nls/normnfkc.nls" );
  4959. dump_norm_table( "nls/normnfkd.nls" );
  4960. dump_norm_table( "nls/normidna.nls" );
  4961. my $chartypes = dump_sortkey_table( "nls/sortdefault.nls", "Windows 10 Sorting Weight Table.txt" );
  4962. dump_locales( "nls/locale.nls", $chartypes );
  4963. foreach my $file (@allfiles) { dump_msdata_codepage( $file ); }
  4964. dump_eucjp_codepage();
  4965. dump_registry_script( "dlls/kernelbase/kernelbase.rgs", %registry_keys );
  4966. exit 0;
  4967. # Local Variables:
  4968. # compile-command: "./make_unicode"
  4969. # End: