473,657 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need UTF-8. But I keep getting UTF-16. Why? How to fix?

I've been struggling for some time now getting a RSS app to work. I'm
creating RSS from existing XML files (transforming via XSLT).

The problem is that the page, itself, is still being sent at UTF-16 when I
create the RSS from XSLT. It's UTF-8 when I'm creating the XML myself via
the DB and an XMLTextWriter.

This gives IE headaches. It adds a space between each character in the XML
and doesn't render it as an XML file.

I'm completely lost as to what, exactly, is causing the page to be sent as
UTF-16 and how/where to fix it. The key code is below:
=============== =============== ============

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Response.Clear( )
Response.Conten tType = "text/xml"
Response.Conten tEncoding = Encoding.Unicod e

...
buildNodeRSS(Re quest.QueryStri ng("pageID"))
...

End Sub
Public Sub buildNodeRSS(By Val pageId As Integer)

Dim siteID As Integer
' query the DB to find out which site this particular node belongs to
....code to grab the siteID...
End Try
' set up the XML file
Dim XMLfile As String
theMenu = retrieveMenuXML .getMenuXML(sit eID)
XMLfile = theMenu.strMenu


'check to see if the file exists in the cache
If System.Web.Http Context.Current .Cache(siteID & "menuXML") Is Nothing Then
'read in the XML file
Dim theMenuXML As menuXML = retrieveMenuXML .getMenuXML(sit eID)
XMLfile = theMenuXML.strM enu
'add the text to the cache object and set timeout
System.Web.Http Context.Current .Cache.Insert(s iteID & "menuXML", XMLfile,
Nothing, DateTime.Now.Ad dMinutes(0.5), TimeSpan.Zero)
Else
'just use the cached version
XMLfile = CType(System.We b.HttpContext.C urrent.Cache(si teID & "menuXML"),
String)
End If

styleSheetFile = "lastUpdatesRSS .xslt"
Dim stylesheet As String = (MapPath(styleS heetFile))
'Create the XslTransform and load the stylesheet.
Dim xslt As XslTransform = New XslTransform
xslt.Load(style sheet)

'Load the XML data file.
Dim doc As XPathDocument = New XPathDocument(s r)

'Create an XsltArgumentLis t.
Dim xslArg As XsltArgumentLis t = New XsltArgumentLis t

xslArg.AddParam ("pageID", "", pageId)
'create the default link prefix param
Dim linkPrefix As String

linkPrefix = "/"

xslArg.AddParam ("linkPrefix ", "", linkPrefix)

Dim ms As MemoryStream = New MemoryStream
xslt.Transform( doc, xslArg, ms, Nothing)
ms.Position = 0
Dim StReader As StreamReader = New StreamReader(ms , Encoding.UTF8)
'Response.Write (sw.ToString)
Response.Write( StReader.ReadTo End().ToString)
End Sub

--
=============== =============== =============== =============== =====
Win prizes searching google:
http://www.blingo.com/friends?ref=hM...nTqhv-2GE1FNtA
Apr 30 '07 #1
1 1193
Response.Conten tEncoding = Encoding.Unicod e

I'm a moron. I've been staring at the above for a while and didn't notice
that 'duh...I'm SETTING it to UTF-16 via unicode'.

Encoding.utf-8 fixed it.

-Darrel
Apr 30 '07 #2

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

Similar topics

0
2434
by: Sofia | last post by:
My name is Sofia and I have for many years been running a personals site, together with my partner, on a non-profit basis. The site is currently not running due to us emigrating, but during its last year we got traffic of between 2000 - 2500 unique visitors per day. We are now about to re-launch the site from Sweden and we need to purchase a script to run it. Having looked at what is available on the net I have realised that we need a...
0
2427
by: Gregory Nans | last post by:
hello, i need some help to 'tree-ify' a string... for example i have strings such as : s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i need))""" and i need to parse them to have a tree representation such as :
7
4384
by: Mike Kamermans | last post by:
I hope someone can help me, because what I'm going through at the moment trying to edit XML documents is enough to make me want to never edit XML again. I'm looking for an XML editor that has a few features that you'd expect in any editor, except nearly none of them seem to have: 1 - Search and repalce with Regular Expressions. 2 - Search and Replace in an Xpath context. 3 - User specified tag-generation for either on a...
3
2623
by: Bob.Henkel | last post by:
I write this to tell you why we won't use postgresql even though we wish we could at a large company. Don't get me wrong I love postgresql in many ways and for many reasons , but fact is fact. If you need more detail I can be glad to prove all my points. Our goal is to make logical systems. We don't want php,perl, or c++ making all the procedure calls and having the host language to be checking for errors and handleing all the...
2
1946
by: Michael R. Pierotti | last post by:
Dim reg As New Regex("^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$") Dim m As Match = reg.Match(txtIPAddress.Text) If m.Success Then 'No need to do anything here Else MessageBox.Show("You need to enter a valid IP Address", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Hand) txtIPAddress.Focus() Return End If
10
2578
by: L. R. Du Broff | last post by:
I own a small business. Need to track a few hundred pieces of rental equipment that can be in any of a few dozen locations. I'm an old-time C language programmer (UNIX environment). If the only tool you know how to use is a hammer, every problem tends to look like a nail. That said, I could solve my problem in C, but it's not the right tool. I need to come into the Windows world, and I need to get this done in Access or something...
23
2531
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
16
2524
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client uses IE to talk with a server. The user on the client (IE) sees an ASP net page containing a TextBox. He can write some text in this text box and push a submit button.
8
2736
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only the sequence nos and it should be such that i can access it through the structure .plz help me .
0
3945
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need Inbox Reply from Craig Somerford <uscos@2barter.net> hide details 10:25 pm (3 minutes ago)
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8740
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...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
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
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
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
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
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.