{"id":364,"date":"2008-05-23T01:15:19","date_gmt":"2008-05-23T01:15:19","guid":{"rendered":"http:\/\/6teen.ru\/?p=58"},"modified":"2008-05-23T01:15:19","modified_gmt":"2008-05-23T01:15:19","slug":"4806","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=364","title":{"rendered":"\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0430"},"content":{"rendered":"<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0430<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>\u041c\u0435\u0442\u043e\u0434\u043e\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439:\n\ntype\n  TCodePage = (cpWin1251, cp866, cpKOI8R);\n  PMap = ^TMap;\n  TMap = array [#$80..#$FF] of Char;\n\nfunction GetMap(CP: TCodePage): PMap;\n{ \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u0438\u0437 CP \u0432 Windows1251\n  (nil \u0434\u043b\u044f CP = cpWin1251) }\nbegin\n  GetMap:=nil;\nend;\n\nfunction DetermineRussian(Buf: PChar; Count: Integer): TCodePage;\nconst\n  ModelBigrams: array [0..33, 0..33] of Byte = (\n   {\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041a\u041b\u041cH\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b\u042c\u042d\u042e\u042f_\u0401}\n{\u0410}(0,20,44,12,22,23,16,60,4,9,63,93,47,110,0,16,35,61,81,1,5,13,24,17,12,4,\n0,0,0,0,14,31,205,1),\n{\u0411}(19,0,0,0,4,19,0,0,8,0,2,15,1,4,41,0,15,5,0,15,0,2,1,0,0,6,16,37,0,0,0,4,\n3,0),\n{\u0412}(97,0,1,0,2,57,0,5,40,0,4,25,2,23,78,2,8,28,4,12,0,1,0,0,8,1,0,40,1,0,0,5\n,106,3),\n{\u0413}(13,0,0,0,9,5,0,0,15,0,1,17,1,2,96,0,24,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,8,0\n),\n{\u0414}(63,0,9,1,2,71,1,0,35,0,3,16,2,22,50,2,19,9,2,25,0,2,1,0,1,0,1,9,4,0,1,5,\n17,4),\n{\u0415}(4,14,15,34,56,22,13,14,2,34,39,77,73,150,6,9,101,64,81,1,0,15,5,12,10,6,\n0,0,0,0,3,4,235,1),\n{\u0416}(13,0,0,0,12,47,0,0,16,0,1,0,0,23,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,2,2\n),\n{\u0417}(76,2,11,3,11,4,1,0,7,0,2,4,11,24,17,0,6,1,0,8,0,0,0,0,0,0,0,16,6,0,1,4,1\n7,0),\n{\u0418}(7,9,32,5,18,60,4,42,31,27,28,46,55,49,12,7,26,60,53,0,5,25,14,28,4,1,0,0\n,0,0,9,56,255,0),\n{\u0419}(0,0,0,0,2,0,0,0,0,0,1,3,0,3,0,0,0,10,3,0,0,0,0,1,1,0,0,0,0,0,0,0,122,0),\n{\u041a}(92,0,3,0,0,7,2,1,39,0,0,27,0,14,110,0,18,5,35,18,0,0,11,0,0,0,0,0,0,0,0,\n0,5,5,0),\n{\u041b}(85,1,0,2,1,70,6,0,85,0,5,3,0,9,67,1,0,9,0,15,0,0,0,2,0,0,0,9,66,0,15,43,\n57,4),\n{\u041c}(44,0,0,0,0,65,0,0,47,0,1,1,10,15,57,7,0,2,0,24,0,0,0,0,0,0,0,28,0,0,0,8,\n109,3),\n{}(139,0,0,1,11,108,0,4,152,0,7,0,1,69,161,0,0,8,25,24,5,1,5,2,0,1,0,83,10,0\n,1,29,38,5),\n{\u041e}(0,72,139,76,74,32,32,19,12,52,21,93,68,72,7,34,93,102,98,1,2,6,6,19,15,2\n,0,0,0,1,4,9,252,2),\n{\u041f}(17,0,0,0,0,43,0,0,14,0,1,9,0,1,125,3,120,1,2,8,0,0,0,0,0,0,0,3,6,0,0,3,2\n,2),\n{\u0420}(151,1,6,4,3,103,7,0,76,0,4,0,11,10,117,1,0,5,9,39,2,5,0,1,3,0,0,24,7,0,1\n,10,22,5),\n{\u0421}(24,1,21,0,3,39,0,0,33,0,56,41,11,15,58,30,5,30,183,16,0,4,1,4,1,0,0,8,25\n,0,1,50,41,2),\n{\u0422}(83,0,43,0,3,87,0,0,71,0,9,3,2,26,180,0,55,33,1,23,1,0,1,4,0,0,0,20,78,0,\n0,5,82,4),\n{\u0423}(3,6,7,14,19,8,13,6,0,1,13,15,10,7,0,12,17,16,19,0,1,3,0,12,5,8,0,0,0,0,2\n2,1,65,0),\n{\u0424}(4,0,0,0,0,4,0,0,11,0,0,1,0,0,9,0,3,0,0,4,1,0,0,0,0,0,0,0,0,0,0,0,2,0),\n{\u0425}(9,0,2,0,0,2,0,0,5,0,0,1,0,5,26,0,4,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,76,0),\n{\u0426}(5,0,0,0,0,16,0,0,48,0,1,0,0,0,4,0,0,0,0,3,0,0,0,0,0,0,0,2,0,0,0,0,3,0),\n{\u0427}(30,0,0,0,0,52,0,0,23,0,3,1,0,14,1,0,0,0,36,5,0,0,0,0,1,0,0,0,1,0,0,0,2,2\n),\n{\u0428}(13,0,0,0,0,28,0,0,17,0,4,4,0,4,3,0,0,0,1,3,0,0,0,0,0,0,0,0,3,0,0,0,1,1),\n{\u0429}(6,0,0,0,0,23,0,0,16,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1),\n{\u042a}(0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0),\n{\u042b}(0,5,14,1,3,28,0,2,0,22,6,19,21,2,0,5,4,7,10,0,0,37,0,3,4,0,0,0,0,0,0,1,8\n4,0),\n{\u042c}(0,1,0,0,0,9,0,10,1,0,13,0,2,26,0,0,0,10,3,0,0,0,1,0,6,0,0,0,0,0,6,4,117,\n0),\n{\u042d}(0,0,0,0,0,0,0,0,0,0,3,3,0,0,0,0,0,0,31,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0),\n{\u042e}(0,5,0,0,3,0,0,0,0,0,0,1,0,0,0,0,0,1,15,0,0,0,1,4,1,15,0,0,0,0,0,0,38,0),\n{\u042f}(0,0,9,2,7,10,3,19,0,0,1,6,7,8,0,0,2,6,19,0,0,3,5,1,0,3,0,0,0,0,5,2,177,0\n),\n{_}(42,80,193,43,109,41,18,53,159,0,144,27,83,176,187,229,70,231,99,47,15,13\n,6,58,7,0,0,0,0,38,0,22,0,2),\n{\u0401}(0,0,0,0,3,0,0,0,0,0,2,4,4,8,0,0,5,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0));\n{ \"\u0440\u0435\u0439\u0442\u0438\u043d\u0433\" \u0431\u0443\u043a\u0432\u044b \u0401 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u044b\u043c 1\/20 \u043e\u0442 \"\u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0430\" \u0431\u0443\u043a\u0432\u044b E,\n  \u0435\u0441\u043b\u0438 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u0441 \u0443\u0447\u0430\u0441\u0442\u0438\u0435\u043c \u0401 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u0438\u043d\u0430\u0447\u0435 - 0 }\ntype\n  TVariation = array [0..33, 0..33] of Integer;\nvar\n  I, J, iC, iPredC, Max: Integer;\n  C: Char;\n  CP: TCodePage;\n  D, MinD, Factor: Double;\n  AMap: PMap;\n  PV: ^TVariation;\n  Vars: array [TCodePage] of TVariation;\nbegin\n  DetermineRussian:=cpWin1251; { \u043f\u043e y\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e }\n  { \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0431\u0438\u0433\u0440\u0430\u043c\u043c }\n  FillChar(Vars, SizeOf(Vars), 0);\n  for CP:=Low(Vars) to High(Vars) do begin\n    AMap:=GetMap(CP);\n    PV:=@Vars[CP];\n    iPredC:=32;\n    for I:=0 to Count - 1 do begin\n      C:=Buf[I];\n      iC:=32;\n      if C >= #128 then begin\n        if AMap <> nil then C:=AMap^[C];\n        if not (C in ['\u0401', '\u0451']) then begin\n          C:=Chr(Ord(C) and not 32); { 'a'..'\u044f' -> '\u0410'..'\u042f' }\n          if C in ['\u0410'..'\u042f'] then iC:=Ord(C) - Ord('\u0410');\n        end\n        else\n          iC:=33;\n      end;\n      Inc(PV^[iPredC, iC]);\n      iPredC:=iC;\n    end;\n  end;\n  { \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 }\n  MinD:=0;\n  for CP:=Low(Vars) to High(Vars) do begin\n    PV:=@Vars[CP];\n    PV^[32, 32]:=0;\n    Max:=1;\n    for I:=0 to 33 do\n      for J:=0 to 33 do\n        if PV^[I, J] > Max then Max:=PV^[I, J];\n    Factor:=255 \/ Max; { \u043d\u043ep\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f }\n    D:=0;\n    for I:=0 to 33 do\n      for J:=0 to 33 do\n        D:=D + Abs(PV^[I, J] * Factor - ModelBigrams[I, J]);\n    if (MinD = 0) or (D < MinD) then begin\n      MinD:=D;\n      DetermineRussian:=CP;\n    end;\n  end;\nend;\n\nbegin\n  { \u0442\u0435\u0441\u0442: \u0441\u043b\u043e\u0432\u043e '\u041f\u0440\u0438\u043c\u0435\u0440' \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430\u0445 (\u0432\u0435p\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0430 \u0442\u0430\u043a\u0438\u0445\n    \u043a\u043ep\u043e\u0442\u043a\u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u0430\u0445 \u0432\u044b\u0441\u043e\u043a\u0430 - \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043by\u0447\u0430\u0435 \u043fp\u043e\u0441\u0442\u043e \u043f\u043e\u0432\u0435\u0437\u043b\u043e!) }\n  writeln(DetermineRussian(#$CF#$F0#$E8#$EC#$E5#$F0, 6) = cpWin1251);\n  writeln(DetermineRussian(#$8F#$E0#$A8#$AC#$A5#$E0, 6) = cp866);\n  writeln(DetermineRussian(#$F0#$D2#$C9#$CD#$C5#$D2, 6) = cpKOI8R);\n  readln;\nend.\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u0442\u0435\u043a\u0441\u0442\u0430<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[364,445],"tags":[610,802,874,1014],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/364"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=364"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/364\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}