473,787 Members | 2,928 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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->CreateAttribut e("unicode");
a1->Value = ??? - what to write here?
...
Stream ^ fs = gcnew FileStream(file name, FileMode::Creat e);
...
XmlWriter^ writer = gcnew XmlTextWriter(f s, 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 8535
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->CreateAttribut e("unicode");
a1->Value = ??? - what to write here?
...
Stream ^ fs = gcnew FileStream(file name, FileMode::Creat e);
...
XmlWriter^ writer = gcnew XmlTextWriter(f s, 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="&#x1A1 2;"/>.

When I use

XmlAttribute ^ a1 = doc->CreateAttribut e("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="&#x1A1 2;"/>.

When I use

XmlAttribute ^ a1 = doc->CreateAttribut e("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="&#x1A1 2;"/>.

When I use

XmlAttribute ^ a1 = doc->CreateAttribut e("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
6488
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 seems to work, and I'm wondering whether there are any other details to consider. My experiments with Idle for Python 2.2 indicate that os.path.join doesn't work as I expect when one of the args is a Unicode string. Everything
27
5151
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
2785
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 value given its utf8 value? Rgds, Sam
3
7775
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 DB and display it onscreen. No matter which way I open the file, convert it to Unicode/leave it as is or what ever, I see all single bytes ok, but double bytes become 2 seperate single bytes. Surely there is an easy way to convert these mixed...
4
6072
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 script that grabs some web pages from the web, regex parse the data and stores it localy to xml file for further use.. at first i had no problem using python minidom and everything concerning
3
1635
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 in Adobe PageMaker, and a lot of the data entered is just cut from PageMaker and pasted into my app. My problem is that PageMaker uses em-dashes, typographer's quotes (the slanty quotes `` and ''), etc. and they remain as such when pasted into...
6
6616
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 performance loss using (multibyte) UNICODE vs (single byte) SQL_ASCII/LATINxxx character encoding? (In terms of extra data, and searching/sorting speeds).
3
2156
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 writing a program that interacts with the user through wxPython (unicode build) and stores & retrieves data using PySQLite. As fas as I know now, both packages are capable of handling Python unicode objects (wxPython returns the values of text...
6
2034
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')" % (track, nbr, idartist, idalbum, path)) where the different variables are returned by the libtagedit python bindings as Unicode. Every time I execute this, I get an exception like this:
0
9655
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
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
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,...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
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
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
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
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.