473,390 Members | 1,746 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,390 software developers and data experts.

Xml and unicode values with &#x...

Hello!

I like to use the XmlTextWriter to write some SVG files.

But in some cases, I need the '&' as '&' and not as &.

Example: <glyph unicode="&#x4c;"/>

Some code-snippet:

XmlDocument ^ doc = gcnew XmlDocument();
....
XmlAttribute ^ a = doc->CreateAttribute("unicode");
a1->Value = ??? - what to write here?
...
Stream ^ fs = gcnew FileStream(filename, FileMode::Create);
...
XmlWriter^ writer = gcnew XmlTextWriter(fs, gcnew UTF8Encoding);
How can I force to write the attribute as &#x4c; and not as &amp;x4c;?

Thanks for any help in advance

Tim
Nov 25 '06 #1
4 8508
Tom Fields wrote:
But in some cases, I need the '&' as '&' and not as &amp;.

Example: <glyph unicode="&#x4c;"/>

Some code-snippet:

XmlDocument ^ doc = gcnew XmlDocument();
....
XmlAttribute ^ a = doc->CreateAttribute("unicode");
a1->Value = ??? - what to write here?
...
Stream ^ fs = gcnew FileStream(filename, FileMode::Create);
...
XmlWriter^ writer = gcnew XmlTextWriter(fs, gcnew UTF8Encoding);
How can I force to write the attribute as &#x4c; and not as &amp;x4c;?
What programming language is that? You simply need to set the Value
property to a string with the Unicode characters you need, with C# or J#
you could simply use e.g.
"\u004C"
to have that character in a string literal.

Or you can simply use
"L"
as that is the character with the Unicode code point 76.

There is no need to escape such characters and there is no easy way to
use XmlDocument or XmlTextWriter to enforce escaping of such characters,
you would need your own custom XmlWriter that escapes the characters you
need.
The DOM does not preserve such numeric characters references, it always
gives you the character itself and not the reference.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 25 '06 #2
Thanks for your answer.

Use managed c++.

For ansi-glyphs, I can use <glyph unicode="A"/and so on.
But for unicode glyphs I have to use <glyph unicode="&#x1A12;"/>.

When I use

XmlAttribute ^ a1 = doc->CreateAttribute("unicode");
a1->Value = "\u01A5";

I get the following warning

warning C4566: character represented by universal-character-name
'\u01A5' cannot be
represented in the currencode page (1252)

und the result (in the xml-file is <glyph unicode="?" />.

Tim
Nov 26 '06 #3
Tom Fields wrote:
Use managed c++.

For ansi-glyphs, I can use <glyph unicode="A"/and so on.
But for unicode glyphs I have to use <glyph unicode="&#x1A12;"/>.

When I use

XmlAttribute ^ a1 = doc->CreateAttribute("unicode");
a1->Value = "\u01A5";
Can you try
a1->Value = L"\u01A5";
?
I don't use managed C++ but some examples on managed C++ on MSDN use
that syntax which then converts to a managed .NET System.String literal
I hope. Generally I think the solution is to find a way to write managed
C++ and include/reference Unicode characters in the source code, not to
try to escape Unicode characters the XML way as XML can deal with
Unicode characters without escaping.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 26 '06 #4
On Sun, 26 Nov 2006 15:08:26 +0100, Tom Fields wrote:
Thanks for your answer.

Use managed c++.

For ansi-glyphs, I can use <glyph unicode="A"/and so on.
But for unicode glyphs I have to use <glyph unicode="&#x1A12;"/>.

When I use

XmlAttribute ^ a1 = doc->CreateAttribute("unicode");
a1->Value = "\u01A5";

I get the following warning

warning C4566: character represented by universal-character-name
'\u01A5' cannot be
represented in the currencode page (1252)

und the result (in the xml-file is <glyph unicode="?" />.

Tim
You can use the InnerXml property instead, as this accepts an XML compliant
string such as "&#x01A5;".

Cheers,
Gadget
Nov 29 '06 #5

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

Similar topics

5
by: Edward K. Ream | last post by:
Am I reading pep 277 correctly? On Windows NT/XP, should filenames always be converted to Unicode using the mbcs encoding? For example, myFile = unicode(__file__, "mbcs", "strict") This...
27
by: EU citizen | last post by:
Do web pages have to be created in unicode in order to use UTF-8 encoding? If so, can anyone name a free application which I can use under Windows 98 to create web pages?
6
by: S. | last post by:
if in my website i am using the sgml { notation, is it accurate to say to my users that the site uses unicode or that it requires unicode? is there a mathematical formula to calculate a unicode...
3
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a...
4
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3...
3
by: Stilgar[bbs.isca.uiowa.edu] | last post by:
I have a VB.NET app that is made up of several fill-in-the-blank-type forms that allows non-technical people convert articles, press releases and publications into XML. For publications created...
6
by: John Sidney-Woollett | last post by:
Hi I need to store accented characters in a postgres (7.4) database, and access the data (mostly) using the postgres JDBC driver (from a web app). Does anyone know if: 1) Is there a...
3
by: KvS | last post by:
Hi all, I've been reading about unicode in general and using it in Python in particular lately as this turns out to be not so straightforward actually. I wanted to aks two questions: 1) I'm...
6
by: Raphael.Benedet | last post by:
Hello, For my application, I would like to execute an SQL query like this: self.dbCursor.execute("INSERT INTO track (name, nbr, idartist, idalbum, path) VALUES ('%s', %s, %s, %s, '%s')" %...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.