0

I am exporting unicode data using Php COM. I have written in top of my web page the below line:

<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>

But when I export the unicode data into a word document using Php COM, It is not coming properly like a unicode, Instood it is coming as shown below:

ಆದಿಯಲà³à²²à²¿ ದೇವರೠಆಕಾಶವನà³à²¨à³

I use the Php COM code to export the data to word document as below:

$unicode_data = "ಆದಿಯಲ್ಲಿ";
$word = new variant(com_get_active_object("word.application"));
$word->Selection->TypeText($unicode_data);

So please suggest me what else should be included to above code to get a unicode in correct format in the word document.

(From comment)

CREATE TABLE kan (
    id int(15) NOT NULL AUTO_INCREMENT, 
    content text CHARACTER SET utf8 NOT NULL, 
    PRIMARY KEY (id)
) ENGINE=MyISAM AUTO_INCREMENT=31105 DEFAULT CHARSET=latin1
Rick James
  • 135,179
  • 13
  • 127
  • 222
Nathan
  • 125
  • 2
  • 13

1 Answers1

1

You wanted some Kannada text like 'ಆದಿಯಲ...'?

You should not have to mention "unicode" anywhere.

Your 'meta' and connection look correct.

Please go to Trouble with utf8 characters; what I see is not what I stored and look at the recommended SELECT .. HEX. Does the hex look something like this (but without spaces)?

E0B286 E0B2A6 E0B2BF E0B2AF

If so, it was stored correctly. If not, then you have "double encoding" and the hex will be more like

C3A0 C2B2 E280A0 C3A0 C2B2 C2A6 C3A0 C2B2

utf8 E0B286 is Unicode 3206=x0C86 representing [ಆ] KANNADA LETTER AA

Community
  • 1
  • 1
Rick James
  • 135,179
  • 13
  • 127
  • 222
  • Yes, the Hex looks exactly like E0B286 E0B2A6 E0B2BF E0B2AF. So there is no problem in the way it is stored. I exported the same unicode data into word document using using http header method and it is exporting correctly but I want to achieve the same export using php com method – Nathan Jul 27 '16 at 04:53
  • Http header method is : "; echo ""; echo ""; echo "".$unicodedata.""; echo ""; echo " – Nathan Jul 27 '16 at 04:57
  • Hmmm... Please provide `SHOW CREATE TABLE` and the `SELECT` statement. – Rick James Jul 27 '16 at 04:58
  • But when i pass the same variable into PHP COM method then it is not exporting in the right format: Selection->TypeText($unicodedata); ?> – Nathan Jul 27 '16 at 04:59
  • Only difference in these two methods i see is: http header method uses echo "meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" which is making the export success. I want to achieve the same charset encoding in php com – Nathan Jul 27 '16 at 05:02
  • A guess: Something is mis-configured in the COM object. (I know nothing about COM.) Suggest starting a new Question with that code in your last comment. (That is, leave MySQL out of the equation.) Need to attract COM folks, not me (mysql folk). – Rick James Jul 27 '16 at 05:04
  • SHOW CREATE TABLE : CREATE TABLE `kan` ( `id` int(15) NOT NULL AUTO_INCREMENT, `content` text CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=31105 DEFAULT CHARSET=latin1 – Nathan Jul 27 '16 at 05:11
  • Any Answers please – Nathan Aug 11 '16 at 11:21
  • I'm out of ideas from a MySQL side. See my suggestion about starting a non-mysql question. – Rick James Aug 11 '16 at 17:45