473,406 Members | 2,707 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,406 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 8510
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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
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
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,...
0
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...

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.