{"id":196,"date":"2012-10-25T23:05:02","date_gmt":"2012-10-25T21:05:02","guid":{"rendered":"http:\/\/my-opinions.info\/?p=196"},"modified":"2012-10-25T23:05:02","modified_gmt":"2012-10-25T21:05:02","slug":"drupal-6-node_import-ansi-to-utf","status":"publish","type":"post","link":"https:\/\/uw-t.com\/ru\/drupal\/drupal-6-node_import-ansi-to-utf","title":{"rendered":"drupal 6 node_import ANSI to utf"},"content":{"rendered":"<p>\u0421\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c node_import \u043d\u0430 drupal 6 \u043a\u0443\u0448\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 ANSI \u0443\u0431\u0438\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432, \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0440\u0430\u0434\u0438\u043a\u0430\u043b\u044c\u043d\u043e, \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043d\u0435 \u0432 UTF-8 \u0442\u043e \u043f\u0435\u0440\u0435\u0433\u043d\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u044d\u0442\u0443 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0443.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435,\u0432 \u0444\u0430\u0439\u043b\u0435 <strong>node_import.admin.inc<\/strong>\u00a0\u043d\u0430\u0439\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/p>\n<pre lang=\"php\">function node_import_add_form_submit_upload_file($form, &amp;$form_state) {<\/pre>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/p>\n<pre lang=\"php\">function node_import_add_form_submit_upload_file($form, &amp;$form_state) {\r\n  $validators = array();\r\n\r\n  $dest = node_import_directory();\r\n\r\n  if (($file = file_save_upload('file_upload', $validators, $dest, FILE_EXISTS_RENAME))) {\r\n    drupal_set_message(t('New file %name uploaded to %path.', array('%name' =&gt; $file-&gt;filename, '%path' =&gt; $file-&gt;filepath)));\r\n    file_set_status($file, FILE_STATUS_PERMANENT);\r\n    $form_state['values']['fid'] = $file-&gt;fid;\r\n  }\r\n\r\n\/*\u041f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u0430 \u0435\u0441\u043b\u0438 \u043e\u043d \u0432 cp1251*\/\r\n\t$fp = fopen($file-&gt;filepath, 'r');\r\n\t$file1 = '';\r\n\twhile (! feof($fp)) {\r\n\t  $file1 .= fgets($fp, 4096);\r\n\t}\r\n\t$get  = mb_detect_encoding($file1, array('utf-8', 'cp1251'));\r\n\tif($get != \"UTF-8\") {\r\n\t\t$file_utf = iconv(\"cp1251\",\"UTF-8\", $file1);\r\n\t\t$tmp_file = fopen($file-&gt;filepath, 'w+');\r\n\t\tfwrite($tmp_file, $file_utf);\r\n\t\tfclose($tmp_file);\r\n\t\t$fp = fopen($file-&gt;filepath, 'r');\t\r\n\t}\r\n\/*\\\u041f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u0430 \u0435\u0441\u043b\u0438 \u043e\u043d \u0432 cp1251\\*\/\r\n\r\n  node_import_add_form_submit_reload($form, $form_state);\r\n}<\/pre>\n<p>\u0420\u0430\u0434 \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0443 \u0442\u043e \u043f\u043e\u043c\u043e\u0433, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0439\u0442\u0435 \u0434\u0440\u0443\u0437\u044c\u044f\u043c \ud83d\ude09<\/p>","protected":false},"excerpt":{"rendered":"<p>\u0421\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c node_import \u043d\u0430 drupal 6 \u043a\u0443\u0448\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 ANSI \u0443\u0431\u0438\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432, \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0440\u0430\u0434\u0438\u043a\u0430\u043b\u044c\u043d\u043e, \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043d\u0435 \u0432 UTF-8 \u0442\u043e \u043f\u0435\u0440\u0435\u0433\u043d\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u044d\u0442\u0443 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0443. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435,\u0432 \u0444\u0430\u0439\u043b\u0435 node_import.admin.inc\u00a0\u043d\u0430\u0439\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e function node_import_add_form_submit_upload_file($form, &amp;$form_state) { \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e &hellip; <a href=\"https:\/\/uw-t.com\/ru\/drupal\/drupal-6-node_import-ansi-to-utf\" class=\"more-link\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435 <span class=\"screen-reader-text\">drupal 6 node_import ANSI to utf<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[15],"tags":[],"class_list":["post-196","post","type-post","status-publish","format-standard","hentry","category-drupal"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/uw-t.com\/ru\/wp-json\/wp\/v2\/posts\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/uw-t.com\/ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/uw-t.com\/ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/uw-t.com\/ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/uw-t.com\/ru\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":5,"href":"https:\/\/uw-t.com\/ru\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":201,"href":"https:\/\/uw-t.com\/ru\/wp-json\/wp\/v2\/posts\/196\/revisions\/201"}],"wp:attachment":[{"href":"https:\/\/uw-t.com\/ru\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/uw-t.com\/ru\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/uw-t.com\/ru\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}