Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2004, 12:13 PM
Registered User
 
Join Date: Sep 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default UTF-8 msxml

Hi There,

  I´ve got a problem using msxml, I create a XML document and set the encoding to UTF-8 (using doc.createProcessingInstruction "xml", " version='1.0' encoding='UTF-8'").

  If I save it, the file is correctly encoded into UTF-8 (using the method save), if I use the .xml method (returns a string with all the content of the document) to get a string, this is encoded with some kind of UTF-16 encoding, is it possible to get this method (or some other that return the XML encoded correctly in the form of a string), to return a UTF-8 string?

(I need to send this string to a C program in a system that only supports UTF-8)

 Thanks a lot,

Luís Pinho

 
Old January 27th, 2004, 12:59 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Not directly, xml property ALWAYS returns utf-16. Do you have any control over the C method?

Joe (MVP - xml)
 
Old January 27th, 2004, 01:09 PM
Registered User
 
Join Date: Sep 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by joefawcett
 Not directly, xml property ALWAYS returns utf-16. Do you have any control over the C method?

Joe (MVP - xml)
Some control (I will have to do the same thing in Java), the code that I must use in C must be HP-UX compatible (I'm using ansi C and libxml2). Is there anything I can do to the string when I detect that it's a UTF-16 string(is this detectable)?

 
Old January 27th, 2004, 01:29 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Not much help from me, I'm afraid, I don't do anything in C++. As you see xml returns a BSTR which I believe is utf-16. You could load an adodb.stream and set the character type etc. and then read it back.

--

Joe
 
Old January 28th, 2004, 06:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Joe's idea of using an ADO Stream object sounds good to me. You can set the encoding on the stream object (set the Type property to adTypeText and the Charset property to "UTF-8"), then pass the stream in as the destination parameter of the DOM.save() method, then use the stream's ReadText method to pass the xml to C.

hth
Phil





Similar Threads
Thread Thread Starter Forum Replies Last Post
encoding="UTF-8" Pankaj C XSLT 3 October 4th, 2007 05:27 PM
UTF-8 sebastian Classic ASP Basics 0 March 16th, 2005 08:22 AM
utf-8 and ascii mail2atulmehta Classic ASP Databases 0 January 26th, 2005 11:22 PM
How to use Scriptupload + UTF-8 ? duydp Classic ASP Professional 1 October 20th, 2004 11:31 AM
UTF-16 dkb XML 14 November 7th, 2003 09:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.