473,508 Members | 2,088 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.WriteString(myString);

it doesn't work.

Anyone ideas?

Thanks.

Linda Chen
Nov 12 '05 #1
1 7593
"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
17940
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
5634
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
7593
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
11508
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
6622
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
6073
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
4269
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
6616
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
1539
by: Kambojia | last post by:
Hi, I want to write Unicode to file , Help me !
0
7226
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
7328
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,...
0
7388
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...
1
7049
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...
0
7499
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...
1
5055
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...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
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 ...
0
422
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...

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.