Re: Win32::OLE->Option('CP') - encoding bug?
Michael Ludwig <[email protected]>
| Newsgroups | gmane.comp.lang.perl.active-perl |
|---|---|
| Message-ID | <20101013193132.GH4252@wladimir> |
Ludwig, Michael schrieb am 13.10.2010 um 14:02 (+0200):
> I think I've had the misfortune to run into a bug in the Win32::OLE
> encoding logic, or possibly at a deeper layer. But maybe there is
> something that I have not yet understood about this issue.
> Let's see how this works in practice using some code involving
> the Microsoft XML library (msxml6.dll):
> add $dom, 'eins';
> add $dom, 'blöd';
> add $dom, 'weiß';
> add $dom, 'café'; # still Latin1, no UTF-8 encoding
> add $dom, 'ανεργία'; # Greek or Russian force UTF-8 encoding
> add $dom, 'убит';
> -------------------------
>
> A data-dependent return value encoding is difficult to work with.
Just to prove this is *not* related to MSXML (and who would have thought
it was?), here's a repro of the Perl script I posted earlier in JScript
(WSF), which does *not* exhibit the Perl or Win32::OLE behaviour of
opportunistically switching the output to another encoding, but works
comme il faut:
\,,,/
(o o)
------oOOo-(_)-oOOo------
<?xml version="1.0" encoding="utf-8"?>
<job>
<script language="JavaScript">
function add( dom, txt) {
var node = dom.createElement( 'E' );
node.appendChild( dom.createTextNode( txt ) );
dom.documentElement.appendChild( node );
var ret = dom.xml;
WScript.echo( ret );
}
var xml = '<U/>';
var dom = WScript.createObject( 'Msxml2.DOMDocument.6.0' );
dom.loadXML( xml );
add(dom, 'eins');
add(dom, 'blöd');
add(dom, 'weiß');
add(dom, 'café');
add(dom, 'ανεργία');
add(dom, 'убит');
</script>
</job>
-------------------------
T:\MiLu :: cscript sz.wsf
<U><E>eins</E></U>
<U><E>eins</E><E>blöd</E></U>
<U><E>eins</E><E>blöd</E><E>weiß</E></U>
<U><E>eins</E><E>blöd</E><E>weiß</E><E>café</E></U>
<U><E>eins</E><E>blöd</E><E>weiß</E><E>café</E><E>ανεργία</E></U>
<U><E>eins</E><E>blöd</E><E>weiß</E><E>café</E><E>ανεργία</E><E>убит</E></U>
--
Michael Ludwig
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs