.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 28th, 2007, 05:18 AM
superprogrammer superprogrammer is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Posts: 794 superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level)superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level)superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 6 Days 17 h 27 m 57 sec
Reputation Power: 7
Send a message via AIM to superprogrammer Send a message via MSN to superprogrammer Send a message via Yahoo to superprogrammer
XML in UTF-8 format

Hi
I am generating the XML using StringBuilder and doing the serialization
The resultant XML is in UTF-16 format
Can someone tel me how I can change it to UTF-8?
__________________
Contact info:
Primary email: advanced.programmer@gmail.com
MSN/email: superprg@hotmail.com
AIM: superprg

Reply With Quote
  #2  
Old November 29th, 2007, 12:44 PM
ptr2void ptr2void is online now
I haz teh codez!
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Dec 2003
Posts: 1,336 ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level)ptr2void User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 10 h 7 m 30 sec
Reputation Power: 715
This is what I'm using:

c# Code:
Original - c# Code
  1. public static string XmlSerialize(object objectToSerialize,
  2.     bool emitUtf8Identifier)
  3. {
  4.     XmlSerializer serializer = new XmlSerializer(
  5.         objectToSerialize.GetType());
  6.    
  7.     // If emitUtf8Identifier is true, the resulting data
  8.     // will have the UTF-8 file marker at the beginning of the stream.
  9.     // This is OK for data to be written to a file, but will cause
  10.     // XmlDocument::LoadXml(serializedData) to fail.
  11.     UTF8Encoding encoding = new UTF8Encoding(emitUtf8Identifier);
  12.     using (MemoryStream mem = new MemoryStream())
  13.     {
  14.         using (StreamWriter writer = new StreamWriter(mem, encoding))
  15.         {
  16.             // Write object to the stream.
  17.             serializer.Serialize(writer, serializable);
  18.  
  19.             // Reset the position for string extraction.
  20.             writer.BaseStream.Position = 0;
  21.         }
  22.  
  23.         return encoding.GetString(mem.ToArray());
  24.     }
  25. }

Reply With Quote
  #3  
Old December 27th, 2007, 03:41 PM
superprogrammer superprogrammer is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Posts: 794 superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level)superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level)superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 6 Days 17 h 27 m 57 sec
Reputation Power: 7
Send a message via AIM to superprogrammer Send a message via MSN to superprogrammer Send a message via Yahoo to superprogrammer
Thanks buddy!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > XML in UTF-8 format


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 12 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek