473,659 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

response.writin g out UTF8 XML. How?

I was having issues before with my XML being sent to the browser as UTF16.
Via my XmlTextWriter, was able to fix this by explicitely setting the
encoding to UTF8:

Dim objX As New XmlTextWriter(R esponse.OutputS tream, Encoding.UTF8)

That fixed the issue.

I'm not generating an XML file using a different method grabbing XML from a
DB and then reading it in as a stringreader, then transforming that via an
XSLT file.

Eventually, I do the XSLT transformation and response.write the result to
the browser.

The problem is that, once again, it's being set witn a UTF16 encoding.

I've tried to explicitely set the response encoding as such:

-------------
xslt.Transform( doc, xslArg, sw, Nothing)
Response.Conten tType = "text/xml"
Response.Conten tEncoding = System.Text.Enc oding.UTF8
Response.Write( sw.ToString)
Response.End()
-------------

But I STILL get the UTF16 declaration in my XML:

<?xml version="1.0" encoding="utf-16"?><rss version="2.0">. ..

Why!?

-Darrel
Jul 17 '07 #1
2 8414
darrel wrote:
The problem is that, once again, it's being set witn a UTF16 encoding.

I've tried to explicitely set the response encoding as such:

-------------
xslt.Transform( doc, xslArg, sw, Nothing)
Response.Conten tType = "text/xml"
Response.Conten tEncoding = System.Text.Enc oding.UTF8
Response.Write( sw.ToString)
Response.End()
-------------

But I STILL get the UTF16 declaration in my XML:

<?xml version="1.0" encoding="utf-16"?><rss version="2.0">. ..
Don't transform to a StringWriter, instead transform directly to
Response.Output :
Response.Conten tType = "applicatio n/xml"
xslt.Transform( doc, xslArg, Response.Output , Nothing)
And make sure your XSLT stylesheet has
<xsl:output method="xml" encoding="UTF-8"/>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 18 '07 #2
Don't transform to a StringWriter, instead transform directly to
Response.Output :
Aha!

So, I have this now:

Response.Conten tType = "text/xml"
Response.Conten tEncoding = System.Text.Enc oding.UTF8
xslt.Transform( doc, xslArg, Response.Output , Nothing)
Response.End()

And that works! However, I've never epxlicitely put the <?xml...tag in my
XSLT. It seems that this is generated for me via the response output. Should
I be explicitly including this in my XSLT file?

-Darrel
Jul 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
17386
by: Tammy | last post by:
Hi, I have an aspx app which needs to post data to a form and read the response. I am confused on whether I should be using the get_url using "POST" method or the post_url using "GET" method. string get_url = "http://scmvs4:9090/gtccinfo/H485W020.HTML"; --url contains a form string post_url = "http://scmvs4:9090/cgi-bin/gticglnk/P485VEGA"; --called by get_Url upon submit
3
2458
by: Brad | last post by:
I have a response filter which injects "standard" html into my pages. The filter works fine when the initial stream is small enough not to buffer...or....if I have a large unbuffered stream (i.e. I set buffer=false on a large page). Now the problem: If I turn on buffering on a large page, the page output (to the browser) is correct a few times (sometines just once, sometime 2-3 times...on the same page) then I seem to either lose data...
1
4158
by: richardtallent | last post by:
(ASP.NET 2.0. Issue presents both on my copy of IIS on my workstation (XP Pro) and my production server (Win2k3). I don't use any proxy servers, anti-spyware apps, etc. Problem occurs using IE6SP2 and Firefox 1.5.02.) I'm writing large, sever-generated XML files to the browser. This method works: Dim xmltxt As New System.IO.StringWriter
2
3035
by: Craig | last post by:
I have the need to write a byte of information to a specific location in a text file. eg. the file looks something like this. FYYNN Line 1 Line 2 <eof>
0
1670
by: ed | last post by:
Hello All. I have seen many posts slightly similar to this question with no answer. Maybe you have some FAQs or something, sorry if I looks repetitive. Here is my Problem: In my application I have a link button inside a module on an IBuySpy Portal to download an excel file. I generate the excel file using the Office 2003
4
5658
by: | last post by:
Hi all, I want to create a method that does the following: 1) Programmatically instantiate a new XmlDataSource control 2) For each file in a named directory, make a "FileSystemItem" element 3) On each FileSystemItem Element, make two child nodes, one with the file name, one with the file size. ie. <filesystemitems> <filesystemitem>
0
2296
by: shintu | last post by:
Hallo, I am trying to write french accented characters é è ê in Excel worksheet using my perl script , But I am stuck here as I couldnt find a way of writing it !: My code: use strict; use warnings;
3
2183
by: Ira.Kovac | last post by:
Hello All, I am trying to fix PHP code developed by somebody else and my knowledge of PHP is very limited so I'd appreciate any help. I have a MySQL database configured to accept UTF-8 in all fields. When I update the database with Unicode via phpMyAdmin web interface I am able to write and save unicode values in all fields.
1
3854
by: Mudcat | last post by:
In short what I'm trying to do is read a document using an xml parser and then upload that data back into a database. I've got the code more or less completed using xml.etree.ElementTree for the parser and dbi/ odbc for my db connection. To fix problems with unicode I built a work-around by mapping unicode characters to equivalent ascii characters and then encoding everything to ascii. That allowed me to build the application and debug...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8748
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.