473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.WriteString(myString);

it doesn't work.

Anyone ideas?

Thanks.

Linda Chen
Nov 12 '05 #1
1 7588
"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.UnicodeEncoding( ) );

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.UnicodeEncoding( 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.UnicodeEncoding( 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
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>',...
0
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)...
1
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...
2
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')...
2
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...
9
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...
2
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...
5
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 =...
1
by: Kambojia | last post by:
Hi, I want to write Unicode to file , Help me !
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.