פורסם 2012 ביוני 3013 שנים תנסה Encode in UTF-8 without BOM. יש לי הרגשה שהתו BOM בהתחלה יכול ליצור את הבעיה.
פורסם 2012 ביוני 3013 שנים מחבר תנסה Encode in UTF-8 without BOM. יש לי הרגשה שהתו BOM בהתחלה יכול ליצור את הבעיה.ניסיתי, לא עובד :\
פורסם 2012 ביולי 113 שנים מחבר על קובץ קיים אתה צריך לעשות Convert to UTF-8 without BOM, לא סתם Encode. זה מה שעשיתי :\ זה לא עוזר עריכה: הcontent-type נשאר text/html למרות שאני מגדיר לו text/html, מה יכול לגרום לזה? :\ עוד עריכה: ברוך ה' אחרי שבוע שדפקתי ת'ראש בקיר מצאתי את הבעיה הHEADERS לא נשלחים כמו שצריך כשהקובץ נמצא עם קידוד UTF-8 אלא רק עם ANSI, והבעיה היא שהטקסט שנשלף מהמסד נתונים היה בעברית ככה שהייתי חייב (או לפחות חשבתי ככה) להגדיר את הקובץ כUTF-8, מה שעשיתי זה שהגדרתי את הקידוד כANSI והוספתי לכל טקסט שנשלף בעברית תג htmlspecialchars שהגדיר אותו ספציפית כUTF-8, ככה הקוד נראה אחרי התיקון: <?php class Controllerzapprod extends Controller { public function plainText($description){ $description = strip_tags(html_entity_decode($description)); $description = str_replace(' ', ' ', $description); $description = str_replace('"', '"', $description ); $description = str_replace("'", ''', $description ); $description = str_replace('<', '<', $description ); $description = str_replace('>', '>', $description ); $description = str_replace("\n", ' ', $description ); $description = str_replace("\r", ' ', $description ); $description = preg_replace('/&#?[a-z0-9]+;/i',' ',$description); // remove any html entities.. $description = preg_replace('/\s{2,}/i', ' ', $description ); return substr($description, 0, 500000 ); } public function index() { if(isset($this->request->get['cat'])){ $output = '<?xml version="1.0" encoding="UTF-8" ?>'; $output .= '<STORE URL="' . HTTP_SERVER . '" DATE="'. date('d.m.Y') .'" TIME="'. date('H:i:s') .'" NAME="'. $this->config->get('config_name') .'" STATUS="ONLINE" ID="0">'; $this->load->model('catalog/product'); $this->load->model('tool/image'); $data = array( 'filter_category_id' => $this->request->get['cat'], 'sort' => '', 'order' => '', 'start' => '', 'limit' => '' ); $products = $this->model_catalog_product->getProducts($data); $output .= '<PRODUCTS>'; foreach ($products as $product) { $output .= '<PRODUCT>'; $output .= '<PRODUCT_NAME>' . htmlspecialchars($product['name'], ENT_COMPAT, 'UTF-8') . '</PRODUCT_NAME>'; $output .= '<PRODUCT_URL>' . HTTP_SERVER . 'index.php?route=product/product&product_id=' . $product['product_id'] . '</PRODUCT_URL>'; $output .= '<DETAILS>' . htmlspecialchars($this->plainText($product['description']), ENT_COMPAT, 'UTF-8') . '</DETAILS>'; $output .= '<MANUFACTURER>' . $this->plainText($product['manufacturer']) . '</MANUFACTURER>'; $output .= '<CATALOG_NUMBER>' . $product['product_id'] . '</CATALOG_NUMBER>'; if ($product['image']) { $output .= '<IMAGE>' . $this->model_tool_image->resize($product['image'], 500, 500) . '</IMAGE>'; } else { $output .= '<IMAGE>' . $this->model_tool_image->resize('no_image.jpg', 500, 500) . '</IMAGE>'; } $output .= '<MODEL>' . $product['model'] . '</MODEL>'; $output .= '<CURRENCY>ILS</CURRENCY>'; if ((float)$product['special']) { $output .= '<PRICE>' . substr($product['price'], 0, strpos($product['special'], '.')) . '</PRICE>'; } else { $output .= '<PRICE>' . substr($product['price'], 0, strpos($product['price'], '.')) . '</PRICE>'; } $output .= '<SHIPMENT_COST>0</SHIPMENT_COST>'; $output .= '<DELIVERY_TIME>7</DELIVERY_TIME>'; $output .= '<WARRANTY />'; $output .= '<TAX />'; $output .= '</PRODUCT>'; } $output .= '</PRODUCTS>'; $output .= '</STORE>'; $this->response->addHeader('Content-Type: text/xml; charset=utf-8'); $this->response->setOutput($output); } else { echo '<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.hd1.co.il/index.php?route=zapindex">'; } }}?>
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.