php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40355 the dcom interface doesn't support the utf8 encoding
Submitted: 2007-02-04 19:45 UTC Modified: 2007-02-05 12:22 UTC
From: info at paolotozzo dot it Assigned:
Status: Not a bug Package: COM related
PHP Version: 5.2.0 OS: WINDOWS
Private report: No CVE-ID: None
 [2007-02-04 19:45 UTC] info at paolotozzo dot it
Description:
------------
I try to test this bug with the MS Word application, with MS Excel and with Adobe Indesign application, but I suppose that also with other applications the result is the same.
If I insert (with COM interface) a text with non standard encoding (like russian language , greek language etc.), I get always strange output. I try to change all the settings in php.ini, I try to use the mbstring and the iconv functions, but the result is the same:
1) I get the '?' symbols
2) I get the strange output

The file .php that I use for test is saved correctly in utf-8 format
I.E. I put a greek text in a variable..if I write this variable in a text file, it work well, but If I use this var for print an output with a com interface, it doesn't work.
I try this with all the last php versions.

Reproduce code:
---------------
<? 
// create a reference to a new COM component (Word)
$word = new COM("word.application") or die("Can't start Word!"); 


// print the version of Word that's now in use
echo "Loading Word, v. {$word->Version}<br>"; 

// set the visibility of the application to 0 (false) 
// to open the application in the forefront, use 1 (true)
$word->Visible = 1; 

// create a new document in Word
$word->Documents->Add(); 

// add text to the new document


//in the next line I assign at $text var a greek text string
$text="????????";

//i try to use the mb, with many combinations of encoding
//but the result is the same if I comment this line
$text=mb_convert_encoding($text, '', "UTF-8");


//I try to write the var in a text file, and it works well
$c=fopen("test.txt","w"); 
fputs($c,($text));


$word->Selection->TypeText($text);

//save the document in the Windows temp directory


// print another message to the screen
echo "Check for the file..."; 
?> 



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-05 12:22 UTC] wharmby@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

I think the problem here is simply that you have not specified which codepage COM is to use to use when
processing strings. This is done via the "codepage" argument
when you instantiate the COM object. You need something
like:

      word = new COM("word.application", NULL, CP_UTF8) 

The default is to use the ANSI code page (CP_ACP).
See http://uk2.php.net/manual/en/class.com.php for further details.

If the problem still persists re-open the defect and I will investigate further.

 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Oct 07 23:05:54 2022 UTC