|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47984 COM automation: garbled utf-8 text
Submitted: 2009-04-16 09:22 UTC Modified: 2015-04-07 14:48 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: js at mcs dot be Assigned:
Status: Not a bug Package: COM related
PHP Version: 5.2.9 OS: Windows XP
Private report: No CVE-ID: None
 [2009-04-16 09:22 UTC] js at mcs dot be
When using the attached script (saved as UTF-8 without BOM) to generate a word document, at the end of the text typed programmatically into word a "?" character gets added. This character is only visible if I press the inverted "P" button on the toolbar. This is a reduced test case, but in real-world scenarios, visibly garbled text is inserted into word.

Reproduce code:
   $word = new COM("word.application", NULL, CP_UTF8);
   $word->Visible = false; // hidden
   $word->Selection->TypeText("This is a t?st...");
   $word = null;
   header("Content-type: text/plain");
   echo "wrote file to ".dirname(__FILE__)."\\test.doc";

Expected result:
The COM automation should accept UTF-8 formatted PHP strings without malforming the string ending when the CP_UTF8 parameter is added.

Actual result:
Broken characters at the end of every string containing non-ASCII characters sent via COM automation.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-09 13:39 UTC] ameoba32 at gmail dot com
This bug is known for ages. Here is duplicate

even patch is available. I have patched php 5.2.3 and it works fine.

How to fix this in upcoming release ?
 [2015-04-07 14:48 UTC]
-Status: Open +Status: Not a bug
 [2015-04-07 14:48 UTC]
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

As amoeba had pointed out: duplicate of bug #37899.
 [2022-03-26 05:05 UTC] giw42161 at uooos dot com
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Sep 30 18:05:52 2022 UTC