473,806 Members | 2,878 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to write unicode using XMLWriter?

I need to write some unicode symbols such as degree symbol
(for example 36°) by using XMLTextWrite but couldn't make
it work. I found the degree char in unicode is '\u030A'
and here is my sample code:

char myChar = '\u030A';
string myString = "36" + myChar.ToString ();
myWriter.WriteS tring(myString) ;

it doesn't work.

Anyone ideas?

Thanks.

Linda Chen
Nov 12 '05 #1
1 7630
"Linda Chen" <li********@faa .gov> wrote in message news:16******** *************** *****@phx.gbl.. .
I need to write some unicode symbols such as degree symbol
(for example 36°) by using XMLTextWrite but couldn't make
it work. I found the degree char in unicode is '\u030A'


Your code looks fine, just verify that when you create the XmlTextWriter
that you do so with a Unicode encoding, for instance,

XmlTextWriter myWriter = new XmlTextWriter( fileStream,
new System.Text.Uni codeEncoding( ) );

If you want to hide the Byte Order Mark (BOM) then make sure that you
use the parameterized UnicodeEncoding contructor:

XmlTextWriter myWriter = new XmlTextWriter( fileStream,
new System.Text.Uni codeEncoding( false, false) );

If on the other hand, you're already doing this, then perhaps you are not
seeing the degree symbol because of the font used by your text editor.
If you turn on the Byte Order Mark,

XmlTextWriter myWriter = new XmlTextWriter( fileStream,
new System.Text.Uni codeEncoding( false, true) );

Then you should be able to load the resulting Unicode XML file into
Microsoft Word (it will auto-detect the encoding if a BOM is present)
as Unicode text. Next, change the Font to "Lucida Sans Unicode,"
and you should see the degree symbol (instead of the rectangle
that indicates that code point doesn't have a glyph in Windows'
current code page).
Derek Harmon
Nov 12 '05 #2

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

Similar topics

3
17978
by: john | last post by:
I need to produce a RTF-document which is filled with data from a database. I've created a RTF-document in WordPad (a template, so to speak) which contains 'placeholders', for example '<dd01>', '<dd02>', etc. I read the entire template into a StringBuilder and then perform a simple 'replace' on it, using a Hashtable. The keys in the Hashtable are strings representing the placeholders and the Hashtable's values contain data
0
5684
by: Ahmed A. | last post by:
This will be very helpfull for many! Using RichTextBox Read/Write Unicode File http://www.microsoft.com/indonesia/msdn/wnf_RichTextBox.as p Private Function ReadFile(ByVal myfile As String) As String Dim myFileStream As Stream = File.Open(myfile, FileMode.Open)
1
7613
by: smithsraj | last post by:
Is there any way to write XML using SAX packages available in Xerces? there is a DOMWriter, but is there any way by which we can use SAX. like in MSXML we have IMXWriter which we can use along with its SAX handler to write XML. -Thanks in advance -Smith
2
11531
by: Frank Potter | last post by:
I want to change an srt file to unicode format so mpalyer can display Chinese subtitles properly. I did it like this: txt=open('dmd-guardian-cd1.srt').read() txt=unicode(txt,'gb18030') open('dmd-guardian-cd1.srt','w').write(txt) But it seems that python can't directly write unicode to a file, I got and error at the 3rd line:
2
6646
by: asenthil | last post by:
i'm trying to read and write files using java... some errors occurs when i'm trying this code.. Error in java: Cannot find symbol location: class java.io.FileOutputStream FileOutputStream fout = new FileOutputStream(outputFile); ^ import java.io.*;
9
6096
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a .net application and am using the xml writer class to create an xml file that opens as an excel file. I am trying to write out the following but am having difficulty. <Row> <Cell ss:StyleID="s87"> <ss:Data ss: Type = "String"> <Font html:Color="#FF0000">M90</Font> <Font>/Thu</Font> </ss:Data> </Cell>
2
4294
by: Hiren Mistry | last post by:
Hello, Experts. as i didnt got solution for "Creating XML from DTD" So finally i started creating DTD parser in C#.net........... Now i m facing problem while i create an xml element with name as "ectd:ectd" using xmlwriter........ but it gives an error or exception as ':' not valide character for xml element name
5
6637
by: Martin | last post by:
I get below error when trying to write unicode xml to a zipfile. zip.writestr('content.xml', content.toxml()) File "/usr/lib/python2.4/zipfile.py", line 460, in writestr zinfo.CRC = binascii.crc32(bytes) # CRC-32 checksum UnicodeEncodeError: 'ascii' codec can't encode character u'\u25cf' in position 2848: ordinal not in range(128) Any ideas?
1
1561
by: Kambojia | last post by:
Hi, I want to write Unicode to file , Help me !
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10366
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
10371
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,...
1
7649
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
5546
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
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
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.