Microsoft KB Archive/291370

= FIX: SAX MSXMLWriter Fails to Save Characters Under Certain Encoding =

Article ID: 291370

Article Last Modified on 8/9/2004

-

APPLIES TO


 * Microsoft XML Core Services 4.0
 * Microsoft XML Parser 3.0 Service Pack 1

-



This article was previously published under Q291370



SYMPTOMS
When you call the parse or parseURL methods of the SAXXMLReader to parse XML data that contains characters that cannot be represented in the output encoding of the Simple API for XML (SAX) MSXMLWriter, you receive the following error message:

Unable to save character to 'iso-8859-1' encoding. -2147467259

For example, the error message occurs when the XML data contains the characters &#B9 FA; &#E1 BB; in GB2312 encoding while the output encoding for the SAX MSXMLWriter is set to ISO-8859-1.



CAUSE
The XML data contains a character that cannot be represented in the ISO-8859-1 character set.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Microsoft XML 3.0 Service Pack 1.

For additional information on other fixes included in Microsoft XML 3.0 Service Pack 1, click the article number below to view the article in the Microsoft Knowledge Base:

292935 INFO: List of Issues Fixed in Microsoft XML 3.0 Service Pack 1

For the latest information and downloads of MSXML, refer to the following Web site:

http://msdn.microsoft.com/xml/default.asp



MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

Download Gb2312.exe now

Release Date: Jun-22-2001

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Steps to Reproduce Behavior
 Create the test XML document. To do this, download the Gb2312.xml file and move the file to the root folder of drive C. Create the test project:  In Microsoft Visual Basic, create a new Standard EXE project. Form1 is created by default. On the Project menu, click to select References, and then select Microsoft ActiveX Data Objects 2.6 Library and Microsoft XML, v3.0. Add a CommandButton to Form1. Command1 is added by default.  Paste the following code into the Click event for Command1: Private Sub Command1_Click Dim writer As New MXXMLWriter30 Dim reader As New SAXXMLReader30 Dim adoStr As New ADODB.Stream adoStr.Type = adTypeBinary adoStr.Open

writer.output = adoStr writer.encoding = &quot;iso-8859-1&quot; On Error GoTo ErrHandler Set reader.contentHandler = writer reader.parseURL &quot;c:\gb2312.xml&quot; Debug.Print adoStr.Size Set writer = Nothing Set reader = Nothing Set adoStr = Nothing

Exit Sub ErrHandler: MsgBox Err.Description & Err.Number End Sub </li></ol> </li> Test: <ol style="list-style-type: lower-alpha;"> Press the F5 key to run the Visual Basic project.</li> Click the CommandButton, and note that you receive the following error message:

Unable to save character to 'iso-8859-1' encoding. -2147467259

</li></ol> </li></ol>

Keywords: kbdownload kbbug kbfix kbmsxml300sp1fix kbmsxmlnosweep KB291370

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.