Spreadsheet_Excel_Writer and Unicode issue

From: Date: Mon, 06 Nov 2006 02:56:33 +0000
Subject: Spreadsheet_Excel_Writer and Unicode issue
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25721@lists.php.net to get a copy of this message
Hello, I am working with the PHP PEAR module Spreadsheet_Excel_Writer, and I am having some success working with Unicode, but there is one issue that is arising that I wonder whether someone might be able to help with. Here's my current code for creating a new worksheet in a workbook and preparing to write (UTF-8-encoded) data to it: $worksheets[$i] = &$workbook->addWorksheet($worksheet_name); $worksheets[$i]->setInputEncoding('UTF-8'); After I have set the input encoding I can successfully write Unicode data to the file (e.g. Japanese characters). The problem is that the worksheet names (on the tabs) also have Unicode characters, but the names are defined when creating/adding a new worksheet, before the input encoding has been defined. Because of this (and probably also because of differences in the way text is written between the tab names and the spreadsheet data), Unicode data in the spreadsheets are fine, but Unicode text in the worksheet tabs is corrupted. I have tried converting the text to different Unicode encodings: //$worksheet_name = iconv('UTF-8', 'UTF-16LE', $worksheet_name); //$worksheet_name = iconv('UTF-8', 'UTF-16BE', $worksheet_name); //$worksheet_name = iconv('UTF-8', 'UTF-16', $worksheet_name); Unfortunately none of these work. I have been able to convert Latin-1 text with extended characters and have it display correctly when I do this: $worksheet_name = iconv('UTF-8', 'WINDOWS-1252', $worksheet_name); But of course this won't work for Japanese. If did try "SJIS" and other variations on the name, but none of them worked. Could anyone provide assistance in coming up with a solution to this issue? Any information and/or assistance is greatly appreciated. Thanks in advance! Best regards, Cary Clark

« previous php.pear.general (#25721) next »